25
25
Display version information and exit.
26
26
"""
27
27
28
- import os
29
- import sys
28
+ import array
30
29
import ast
30
+ import codecs
31
31
import getopt
32
+ import os
32
33
import struct
33
- import array
34
+ import sys
34
35
from email .parser import HeaderParser
35
- import codecs
36
36
37
37
__version__ = "1.2"
38
38
@@ -114,7 +114,7 @@ def make(filename, outfile):
114
114
try :
115
115
with open (infile , 'rb' ) as f :
116
116
lines = f .readlines ()
117
- except IOError as msg :
117
+ except OSError as msg :
118
118
print (msg , file = sys .stderr )
119
119
sys .exit (1 )
120
120
@@ -127,6 +127,7 @@ def make(filename, outfile):
127
127
sys .exit (1 )
128
128
129
129
section = msgctxt = None
130
+ msgid = msgstr = b''
130
131
fuzzy = 0
131
132
132
133
# Start off assuming Latin-1, so everything decodes without failure,
@@ -178,7 +179,7 @@ def make(filename, outfile):
178
179
# This is a message with plural forms
179
180
elif l .startswith ('msgid_plural' ):
180
181
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 } ' ,
182
183
file = sys .stderr )
183
184
sys .exit (1 )
184
185
l = l [12 :]
@@ -189,15 +190,15 @@ def make(filename, outfile):
189
190
section = STR
190
191
if l .startswith ('msgstr[' ):
191
192
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 } ' ,
193
194
file = sys .stderr )
194
195
sys .exit (1 )
195
196
l = l .split (']' , 1 )[1 ]
196
197
if msgstr :
197
198
msgstr += b'\0 ' # Separator of the various plural forms
198
199
else :
199
200
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 } ' ,
201
202
file = sys .stderr )
202
203
sys .exit (1 )
203
204
l = l [6 :]
@@ -213,8 +214,7 @@ def make(filename, outfile):
213
214
elif section == STR :
214
215
msgstr += l .encode (encoding )
215
216
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 )
218
218
print (l , file = sys .stderr )
219
219
sys .exit (1 )
220
220
# Add last entry
@@ -227,7 +227,7 @@ def make(filename, outfile):
227
227
try :
228
228
with open (outfile ,"wb" ) as f :
229
229
f .write (output )
230
- except IOError as msg :
230
+ except OSError as msg :
231
231
print (msg , file = sys .stderr )
232
232
233
233
0 commit comments