2525 Display version information and exit.
2626"""
2727
28- import os
29- import sys
28+ import array
3029import ast
3130import getopt
31+ import os
3232import struct
33- import array
33+ import sys
3434from email .parser import HeaderParser
3535
3636__version__ = "1.2"
3737
38+
3839MESSAGES = {}
3940
4041
@@ -112,11 +113,12 @@ def make(filename, outfile):
112113 try :
113114 with open (infile , 'rb' ) as f :
114115 lines = f .readlines ()
115- except IOError as msg :
116+ except OSError as msg :
116117 print (msg , file = sys .stderr )
117118 sys .exit (1 )
118119
119120 section = msgctxt = None
121+ msgid = msgstr = b''
120122 fuzzy = 0
121123
122124 # Start off assuming Latin-1, so everything decodes without failure,
@@ -168,7 +170,7 @@ def make(filename, outfile):
168170 # This is a message with plural forms
169171 elif l .startswith ('msgid_plural' ):
170172 if section != ID :
171- print ('msgid_plural not preceded by msgid on %s:%d' % ( infile , lno ) ,
173+ print (f 'msgid_plural not preceded by msgid on { infile } : { lno } ' ,
172174 file = sys .stderr )
173175 sys .exit (1 )
174176 l = l [12 :]
@@ -179,15 +181,15 @@ def make(filename, outfile):
179181 section = STR
180182 if l .startswith ('msgstr[' ):
181183 if not is_plural :
182- print ('plural without msgid_plural on %s:%d' % ( infile , lno ) ,
184+ print (f 'plural without msgid_plural on { infile } : { lno } ' ,
183185 file = sys .stderr )
184186 sys .exit (1 )
185187 l = l .split (']' , 1 )[1 ]
186188 if msgstr :
187189 msgstr += b'\0 ' # Separator of the various plural forms
188190 else :
189191 if is_plural :
190- print ('indexed msgstr required for plural on %s:%d' % ( infile , lno ) ,
192+ print (f 'indexed msgstr required for plural on { infile } : { lno } ' ,
191193 file = sys .stderr )
192194 sys .exit (1 )
193195 l = l [6 :]
@@ -203,8 +205,7 @@ def make(filename, outfile):
203205 elif section == STR :
204206 msgstr += l .encode (encoding )
205207 else :
206- print ('Syntax error on %s:%d' % (infile , lno ), \
207- 'before:' , file = sys .stderr )
208+ print (f'Syntax error on { infile } :{ lno } before:' , file = sys .stderr )
208209 print (l , file = sys .stderr )
209210 sys .exit (1 )
210211 # Add last entry
@@ -217,7 +218,7 @@ def make(filename, outfile):
217218 try :
218219 with open (outfile ,"wb" ) as f :
219220 f .write (output )
220- except IOError as msg :
221+ except OSError as msg :
221222 print (msg , file = sys .stderr )
222223
223224
0 commit comments