if l[0] == '#' and section == STR:
add(msgid, msgstr, fuzzy)
section = None
fuzzy = 0
if l[:2] == '#,' and l.find('fuzzy'):
fuzzy = 1
if l[0] == '#':
continue
if l.startswith('msgid'):
if section == STR:
add(msgid, msgstr, fuzzy)
section = ID
l = l[5:]
msgid = msgstr = ''
elif l.startswith('msgstr'):
section = STR
l = l[6:]
l = l.strip()
if not l:
continue
l = eval(l)
if section == ID:
msgid += l
elif section == STR:
msgstr += l
else:
print >> sys.stderr, 'Syntax error on %s:%d' % (infile, lno), \
'before:'
print >> sys.stderr, l
sys.exit(1)
if section == STR:
add(msgid, msgstr, fuzzy)
output = generateDict()
try:
open(outfile,"wb").write(output)
except IOError,msg:
print >> sys.stderr, msg
return outfile