25
25
Display version information and exit.
26
26
"""
27
27
28
- import os
29
- import sys
28
+ import array
30
29
import ast
31
30
import getopt
31
+ import os
32
32
import struct
33
- import array
33
+ import sys
34
34
from email .parser import HeaderParser
35
35
36
36
__version__ = "1.2"
37
37
38
+
38
39
MESSAGES = {}
39
40
40
41
@@ -112,11 +113,12 @@ def make(filename, outfile):
112
113
try :
113
114
with open (infile , 'rb' ) as f :
114
115
lines = f .readlines ()
115
- except IOError as msg :
116
+ except OSError as msg :
116
117
print (msg , file = sys .stderr )
117
118
sys .exit (1 )
118
119
119
120
section = msgctxt = None
121
+ msgid = msgstr = b''
120
122
fuzzy = 0
121
123
122
124
# Start off assuming Latin-1, so everything decodes without failure,
@@ -168,7 +170,7 @@ def make(filename, outfile):
168
170
# This is a message with plural forms
169
171
elif l .startswith ('msgid_plural' ):
170
172
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 } ' ,
172
174
file = sys .stderr )
173
175
sys .exit (1 )
174
176
l = l [12 :]
@@ -179,15 +181,15 @@ def make(filename, outfile):
179
181
section = STR
180
182
if l .startswith ('msgstr[' ):
181
183
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 } ' ,
183
185
file = sys .stderr )
184
186
sys .exit (1 )
185
187
l = l .split (']' , 1 )[1 ]
186
188
if msgstr :
187
189
msgstr += b'\0 ' # Separator of the various plural forms
188
190
else :
189
191
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 } ' ,
191
193
file = sys .stderr )
192
194
sys .exit (1 )
193
195
l = l [6 :]
@@ -203,8 +205,7 @@ def make(filename, outfile):
203
205
elif section == STR :
204
206
msgstr += l .encode (encoding )
205
207
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 )
208
209
print (l , file = sys .stderr )
209
210
sys .exit (1 )
210
211
# Add last entry
@@ -217,7 +218,7 @@ def make(filename, outfile):
217
218
try :
218
219
with open (outfile ,"wb" ) as f :
219
220
f .write (output )
220
- except IOError as msg :
221
+ except OSError as msg :
221
222
print (msg , file = sys .stderr )
222
223
223
224
0 commit comments