if not options.outfile:
outfile = sys.stdout
else:
- outfile = open(options.outfile, 'w')
+ outfile = codecs.open(options.outfile, encoding='utf-8', mode='w')
for insert in pot.sql:
outfile.write(insert + "\n")
else:
Source event definitions are structured as follows:
{
- MSG_ID1: "This is a message with 1 variable - ${0}.",
- MSG_ID2: "This is a message with two variables: ${0} and ${1}."
+ "MSG_ID1": "This is a message with 1 variable - ${0}.",
+ "MSG_ID2": "This is a message with two variables: ${0} and ${1}."
}
Note that this is a deliberately limited subset of the variable substitution
# GNU General Public License for more details.
import basel10n
+import codecs
import optparse
import polib
import re
# Avoid generating duplicate entries by keeping track of msgids
msgids = dict()
- bundle = simplejson.load(open(source, 'r'))
+ bundle = simplejson.load(codecs.open(source, encoding='utf-8', mode='r'))
for key, value in bundle.iteritems():
if value in msgids:
pot.loadpo(options.create)
pot.create_bundle()
if options.outfile:
- outfile = open(options.outfile, 'w')
+ outfile = codecs.open(options.outfile, encoding='utf-8', mode='w')
simplejson.dump(pot.msgs, outfile, indent=4)
else:
print(simplejson.dumps(pot.msgs, indent=4))
# GNU General Public License for more details.
import basel10n
+import codecs
import optparse
import polib
import sys
pot.loadpo(options.entity)
pot.create_entity()
if options.outfile:
- outfile = open(options.outfile, 'w')
+ outfile = codecs.open(options.outfile, encoding='utf-8', mode='w')
for entity in pot.definitions:
outfile.write(entity + "\n")
else:
elif options.convert:
pot.get_strings(options.convert)
if options.outfile:
- outfile = open(options.outfile, 'w')
+ outfile = codecs.open(options.outfile, encoding='utf-8', mode='w')
outfile.write(pot.idl)
else:
sys.stdout.write(pot.idl)
# GNU General Public License for more details.
import basel10n
+import codecs
import optparse
import polib
import re
pot.loadpo(options.create)
pot.create_events()
if options.outfile:
- outfile = open(options.outfile, 'w')
+ outfile = codecs.open(options.outfile, encoding='utf-8', mode='w')
outfile.write(head)
for event in pot.definitions:
outfile.write(event + "\n")
return field
if __name__ == '__main__':
+ import codecs
import copy
import os
import re
if (not re.compile(r'^040010-1\d\d\d-f.html').search(filename)):
continue
print filename
- devnull = open('/dev/null', 'w')
+ devnull = codecs.open('/dev/null', encoding='utf-8', mode='w')
file = subprocess.Popen(
('tidy', '-asxml', '-n', '-q', '-utf8', filename),
stdout=subprocess.PIPE, stderr=devnull).communicate()[0]
if (field):
ALL_MY_FIELDS.add_field(field)
- MARCOUT = open('marcedit-tooltips-fr.xml', 'w')
+ MARCOUT = codecs.open('marcedit-tooltips-fr.xml', encoding='utf-8', mode='w')
MARCOUT.write(ALL_MY_FIELDS.to_xml().encode('UTF-8'))
MARCOUT.close()