[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Stripping 'charset=' from po files [the sequal]

From: Branko ÄŒibej <brane_at_xbc.nu>
Date: 2004-05-26 08:11:39 CEST

Erik Hülsmann wrote:

>@@ -0,0 +1,23 @@
>+#
>+# strip-po-charset.py
>+#
>+
>+import sys
>+
>+def strip_po_charset(inp, out):
>+
>+ for line in inp.xreadlines():
>
>
We only require Python 2.0. xreadlines appeared in 2.1.

Just read the whole thing into memory in one go and do a simple
string.replace.

>+ if line.find("\"Content-Type: text/plain; charset=UTF-8\\n\"") == -1:
>+ out.write(line)
>+
>+
>+def main():
>+
>+ if len(sys.argv) != 3:
>+ print "Unsupported number of arguments; 2 required."
>
>
Would be nice to say _which_ arguments. "Usage: foo arg1 arg2"...

>+ sys.exit(1)
>+
>+ strip_po_charset(open(sys.argv[1],'r'), open(sys.argv[2],'w'))
>+
>+if __name__ == '__main__':
>+ main()
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed May 26 08:13:18 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.