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
|
|
@ -8,6 +8,7 @@
|
|||
"""
|
||||
import locale
|
||||
import sys
|
||||
|
||||
_locale = locale
|
||||
|
||||
# Location of the X11 alias file.
|
||||
|
|
@ -100,16 +101,15 @@ def parse_glibc_supported(filename):
|
|||
def pprint(data):
|
||||
items = sorted(data.items())
|
||||
for k, v in items:
|
||||
print(' %-40s%a,' % ('%a:' % k, v))
|
||||
print(f" {k!a:<40}{v!a},")
|
||||
|
||||
def print_differences(data, olddata):
|
||||
items = sorted(olddata.items())
|
||||
for k, v in items:
|
||||
if k not in data:
|
||||
print('# removed %a' % k)
|
||||
print(f'# removed {k!a}')
|
||||
elif olddata[k] != data[k]:
|
||||
print('# updated %a -> %a to %a' % \
|
||||
(k, olddata[k], data[k]))
|
||||
print(f'# updated {k!a} -> {olddata[k]!a} to {data[k]!a}')
|
||||
# Additions are not mentioned
|
||||
|
||||
def optimize(data):
|
||||
|
|
@ -132,7 +132,7 @@ def check(data):
|
|||
errors = 0
|
||||
for k, v in data.items():
|
||||
if locale.normalize(k) != v:
|
||||
print('ERROR: %a -> %a != %a' % (k, locale.normalize(k), v),
|
||||
print(f'ERROR: {k!a} -> {locale.normalize(k)!a} != {v!a}',
|
||||
file=sys.stderr)
|
||||
errors += 1
|
||||
return errors
|
||||
|
|
@ -142,10 +142,10 @@ def check(data):
|
|||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--locale-alias', default=LOCALE_ALIAS,
|
||||
help='location of the X11 alias file '
|
||||
'(default: %a)' % LOCALE_ALIAS)
|
||||
f'(default: {LOCALE_ALIAS})')
|
||||
parser.add_argument('--glibc-supported', default=SUPPORTED,
|
||||
help='location of the glibc SUPPORTED locales file '
|
||||
'(default: %a)' % SUPPORTED)
|
||||
f'(default: {SUPPORTED})')
|
||||
args = parser.parse_args()
|
||||
|
||||
data = locale.locale_alias.copy()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue