diff options
author | Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> | 2021-07-06 16:22:07 +0200 |
---|---|---|
committer | Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> | 2021-07-16 19:04:20 +0200 |
commit | 41458fafa0996660890099d8527756c3582282cf (patch) | |
tree | cb175a359729cfcd27a8e6040444f84b58d78249 /util/locale_database/cldr2qlocalexml.py | |
parent | 65a0e04072050c9827f39aacda267562fd02c37c (diff) |
locale_database: Use f-strings in Python code
Replace most uses of str.format() and string arithmetic by f-strings.
This results in more compact code and the code is easier to read
when using an appropriate editor.
Task-number: QTBUG-83488
Pick-to: 6.2
Change-Id: I3409f745b5d0324985cbd5690f5eda8d09b869ca
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'util/locale_database/cldr2qlocalexml.py')
-rwxr-xr-x | util/locale_database/cldr2qlocalexml.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/util/locale_database/cldr2qlocalexml.py b/util/locale_database/cldr2qlocalexml.py index fc876a2c50..5f67ee708b 100755 --- a/util/locale_database/cldr2qlocalexml.py +++ b/util/locale_database/cldr2qlocalexml.py @@ -61,10 +61,10 @@ from cldr import CldrReader from qlocalexml import QLocaleXmlWriter def usage(name, err, message = ''): - err.write("""Usage: {} path/to/cldr/common/main [out-file.xml] -""".format(name)) # TODO: expand command-line, improve help message + err.write(f"""Usage: {name} path/to/cldr/common/main [out-file.xml] +""") # TODO: expand command-line, improve help message if message: - err.write('\n' + message + '\n') + err.write(f'\n{message}\n') def main(args, out, err): # TODO: make calendars a command-line option @@ -78,22 +78,21 @@ def main(args, out, err): root = args.pop(0) if not os.path.exists(os.path.join(root, 'common', 'main', 'root.xml')): - usage(name, err, - 'First argument is the root of the CLDR tree: found no common/main/root.xml under ' - + root) + usage(name, err, 'First argument is the root of the CLDR tree: ' + f'found no common/main/root.xml under {root}') return 1 xml = args.pop(0) if args else None if not xml or xml == '-': emit = out elif not xml.endswith('.xml'): - usage(name, err, 'Please use a .xml extension on your output file name, not ' + xml) + usage(name, err, f'Please use a .xml extension on your output file name, not {xml}') return 1 else: try: emit = open(xml, 'w') except IOError as e: - usage(name, err, 'Failed to open "{}" to write output to it\n'.format(xml)) + usage(name, err, f'Failed to open "{xml}" to write output to it\n') return 1 if args: |