2525 Display version information and exit.
2626"""
2727
28- import os
29- import sys
28+ import array
3029import ast
30+ import codecs
3131import getopt
32+ import os
3233import struct
33- import array
34+ import sys
3435from email .parser import HeaderParser
35- import codecs
3636
3737__version__ = "1.2"
3838
@@ -114,7 +114,7 @@ def make(filename, outfile):
114114 try :
115115 with open (infile , 'rb' ) as f :
116116 lines = f .readlines ()
117- except IOError as msg :
117+ except OSError as msg :
118118 print (msg , file = sys .stderr )
119119 sys .exit (1 )
120120
@@ -127,6 +127,7 @@ def make(filename, outfile):
127127 sys .exit (1 )
128128
129129 section = msgctxt = None
130+ msgid = msgstr = b''
130131 fuzzy = 0
131132
132133 # Start off assuming Latin-1, so everything decodes without failure,
@@ -178,7 +179,7 @@ def make(filename, outfile):
178179 # This is a message with plural forms
179180 elif l .startswith ('msgid_plural' ):
180181 if section != ID :
181- print ('msgid_plural not preceded by msgid on %s:%d' % ( infile , lno ) ,
182+ print (f 'msgid_plural not preceded by msgid on { infile } : { lno } ' ,
182183 file = sys .stderr )
183184 sys .exit (1 )
184185 l = l [12 :]
@@ -189,15 +190,15 @@ def make(filename, outfile):
189190 section = STR
190191 if l .startswith ('msgstr[' ):
191192 if not is_plural :
192- print ('plural without msgid_plural on %s:%d' % ( infile , lno ) ,
193+ print (f 'plural without msgid_plural on { infile } : { lno } ' ,
193194 file = sys .stderr )
194195 sys .exit (1 )
195196 l = l .split (']' , 1 )[1 ]
196197 if msgstr :
197198 msgstr += b'\0 ' # Separator of the various plural forms
198199 else :
199200 if is_plural :
200- print ('indexed msgstr required for plural on %s:%d' % ( infile , lno ) ,
201+ print (f 'indexed msgstr required for plural on { infile } : { lno } ' ,
201202 file = sys .stderr )
202203 sys .exit (1 )
203204 l = l [6 :]
@@ -213,8 +214,7 @@ def make(filename, outfile):
213214 elif section == STR :
214215 msgstr += l .encode (encoding )
215216 else :
216- print ('Syntax error on %s:%d' % (infile , lno ), \
217- 'before:' , file = sys .stderr )
217+ print (f'Syntax error on { infile } :{ lno } before:' , file = sys .stderr )
218218 print (l , file = sys .stderr )
219219 sys .exit (1 )
220220 # Add last entry
@@ -227,7 +227,7 @@ def make(filename, outfile):
227227 try :
228228 with open (outfile ,"wb" ) as f :
229229 f .write (output )
230- except IOError as msg :
230+ except OSError as msg :
231231 print (msg , file = sys .stderr )
232232
233233
0 commit comments