mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-138286: Run `ruff on Tools/i18n` (#138287)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
This commit is contained in:
parent
15e37ea6b7
commit
78acd8e95e
5 changed files with 36 additions and 22 deletions
|
|
@ -24,14 +24,14 @@
|
|||
Display version information and exit.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import ast
|
||||
import getopt
|
||||
import struct
|
||||
import array
|
||||
from email.parser import HeaderParser
|
||||
import ast
|
||||
import codecs
|
||||
import getopt
|
||||
import os
|
||||
import struct
|
||||
import sys
|
||||
from email.parser import HeaderParser
|
||||
|
||||
__version__ = "1.2"
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ def make(filename, outfile):
|
|||
try:
|
||||
with open(infile, 'rb') as f:
|
||||
lines = f.readlines()
|
||||
except IOError as msg:
|
||||
except OSError as msg:
|
||||
print(msg, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
|
@ -126,6 +126,7 @@ def make(filename, outfile):
|
|||
sys.exit(1)
|
||||
|
||||
section = msgctxt = None
|
||||
msgid = msgstr = b''
|
||||
fuzzy = 0
|
||||
|
||||
# Start off assuming Latin-1, so everything decodes without failure,
|
||||
|
|
@ -177,7 +178,7 @@ def make(filename, outfile):
|
|||
# This is a message with plural forms
|
||||
elif l.startswith('msgid_plural'):
|
||||
if section != ID:
|
||||
print('msgid_plural not preceded by msgid on %s:%d' % (infile, lno),
|
||||
print(f'msgid_plural not preceded by msgid on {infile}:{lno}',
|
||||
file=sys.stderr)
|
||||
sys.exit(1)
|
||||
l = l[12:]
|
||||
|
|
@ -188,7 +189,7 @@ def make(filename, outfile):
|
|||
section = STR
|
||||
if l.startswith('msgstr['):
|
||||
if not is_plural:
|
||||
print('plural without msgid_plural on %s:%d' % (infile, lno),
|
||||
print(f'plural without msgid_plural on {infile}:{lno}',
|
||||
file=sys.stderr)
|
||||
sys.exit(1)
|
||||
l = l.split(']', 1)[1]
|
||||
|
|
@ -196,7 +197,7 @@ def make(filename, outfile):
|
|||
msgstr += b'\0' # Separator of the various plural forms
|
||||
else:
|
||||
if is_plural:
|
||||
print('indexed msgstr required for plural on %s:%d' % (infile, lno),
|
||||
print(f'indexed msgstr required for plural on {infile}:{lno}',
|
||||
file=sys.stderr)
|
||||
sys.exit(1)
|
||||
l = l[6:]
|
||||
|
|
@ -212,8 +213,7 @@ def make(filename, outfile):
|
|||
elif section == STR:
|
||||
msgstr += l.encode(encoding)
|
||||
else:
|
||||
print('Syntax error on %s:%d' % (infile, lno), \
|
||||
'before:', file=sys.stderr)
|
||||
print(f'Syntax error on {infile}:{lno} before:', file=sys.stderr)
|
||||
print(l, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
# Add last entry
|
||||
|
|
@ -226,7 +226,7 @@ def make(filename, outfile):
|
|||
try:
|
||||
with open(outfile,"wb") as f:
|
||||
f.write(output)
|
||||
except IOError as msg:
|
||||
except OSError as msg:
|
||||
print(msg, file=sys.stderr)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue