2424 Display version information and exit.
2525"""
2626
27- import os
28- import sys
27+ import array
2928import ast
29+ import codecs
3030import getopt
31+ import os
3132import struct
32- import array
33+ import sys
3334from email .parser import HeaderParser
34- import codecs
3535
3636__version__ = "1.2"
3737
@@ -113,7 +113,7 @@ def make(filename, outfile):
113113 try :
114114 with open (infile , 'rb' ) as f :
115115 lines = f .readlines ()
116- except IOError as msg :
116+ except OSError as msg :
117117 print (msg , file = sys .stderr )
118118 sys .exit (1 )
119119
@@ -126,6 +126,7 @@ def make(filename, outfile):
126126 sys .exit (1 )
127127
128128 section = msgctxt = None
129+ msgid = msgstr = b''
129130 fuzzy = 0
130131
131132 # Start off assuming Latin-1, so everything decodes without failure,
@@ -177,7 +178,7 @@ def make(filename, outfile):
177178 # This is a message with plural forms
178179 elif l .startswith ('msgid_plural' ):
179180 if section != ID :
180- print ('msgid_plural not preceded by msgid on %s:%d' % ( infile , lno ) ,
181+ print (f 'msgid_plural not preceded by msgid on { infile } : { lno } ' ,
181182 file = sys .stderr )
182183 sys .exit (1 )
183184 l = l [12 :]
@@ -188,15 +189,15 @@ def make(filename, outfile):
188189 section = STR
189190 if l .startswith ('msgstr[' ):
190191 if not is_plural :
191- print ('plural without msgid_plural on %s:%d' % ( infile , lno ) ,
192+ print (f 'plural without msgid_plural on { infile } : { lno } ' ,
192193 file = sys .stderr )
193194 sys .exit (1 )
194195 l = l .split (']' , 1 )[1 ]
195196 if msgstr :
196197 msgstr += b'\0 ' # Separator of the various plural forms
197198 else :
198199 if is_plural :
199- print ('indexed msgstr required for plural on %s:%d' % ( infile , lno ) ,
200+ print (f 'indexed msgstr required for plural on { infile } : { lno } ' ,
200201 file = sys .stderr )
201202 sys .exit (1 )
202203 l = l [6 :]
@@ -212,8 +213,7 @@ def make(filename, outfile):
212213 elif section == STR :
213214 msgstr += l .encode (encoding )
214215 else :
215- print ('Syntax error on %s:%d' % (infile , lno ), \
216- 'before:' , file = sys .stderr )
216+ print (f'Syntax error on { infile } :{ lno } before:' , file = sys .stderr )
217217 print (l , file = sys .stderr )
218218 sys .exit (1 )
219219 # Add last entry
@@ -226,7 +226,7 @@ def make(filename, outfile):
226226 try :
227227 with open (outfile ,"wb" ) as f :
228228 f .write (output )
229- except IOError as msg :
229+ except OSError as msg :
230230 print (msg , file = sys .stderr )
231231
232232
0 commit comments