--- a/devtools/test/unittest_i18n.py Wed Dec 09 14:20:30 2015 +0100
+++ b/devtools/test/unittest_i18n.py Thu Dec 10 17:50:46 2015 +0100
@@ -32,21 +32,22 @@
"""load a po file and return a set of encountered (msgid, msgctx)"""
msgs = set()
msgid = msgctxt = None
- for line in open(fname):
- if line.strip() in ('', '#'):
- continue
- if line.startswith('msgstr'):
- assert not (msgid, msgctxt) in msgs
- msgs.add( (msgid, msgctxt) )
- msgid = msgctxt = None
- elif line.startswith('msgid'):
- msgid = line.split(' ', 1)[1][1:-1]
- elif line.startswith('msgctx'):
- msgctxt = line.split(' ', 1)[1][1: -1]
- elif msgid is not None:
- msgid += line[1:-1]
- elif msgctxt is not None:
- msgctxt += line[1:-1]
+ with open(fname) as fobj:
+ for line in fobj:
+ if line.strip() in ('', '#'):
+ continue
+ if line.startswith('msgstr'):
+ assert not (msgid, msgctxt) in msgs
+ msgs.add( (msgid, msgctxt) )
+ msgid = msgctxt = None
+ elif line.startswith('msgid'):
+ msgid = line.split(' ', 1)[1][1:-1]
+ elif line.startswith('msgctx'):
+ msgctxt = line.split(' ', 1)[1][1: -1]
+ elif msgid is not None:
+ msgid += line[1:-1]
+ elif msgctxt is not None:
+ msgctxt += line[1:-1]
return msgs