diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2022-10-17 10:58:31 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2022-11-01 19:14:14 +0200 |
commit | 0de7e7a0664b7521dd722faf68a5bcf988ebb011 (patch) | |
tree | e7d8127579e8cd45f3fc5ba667e05432bd9b5a91 /util | |
parent | b77da049bc76ca809e7e2b58e0d554a3bf865b56 (diff) |
LocaleDB: Make passing qtbase root dir on command-lines optional
We can easily enough obtain the root of the present source tree using
the value of __file__, so might as well do so.
Change-Id: If14773ac1127278b6018a090c0b376437b9c6eec
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-x | util/locale_database/cldr2qtimezone.py | 17 | ||||
-rw-r--r-- | util/locale_database/localetools.py | 3 | ||||
-rwxr-xr-x | util/locale_database/qlocalexml2cpp.py | 14 |
3 files changed, 21 insertions, 13 deletions
diff --git a/util/locale_database/cldr2qtimezone.py b/util/locale_database/cldr2qtimezone.py index 5517651a98..a2e43d03b7 100755 --- a/util/locale_database/cldr2qtimezone.py +++ b/util/locale_database/cldr2qtimezone.py @@ -4,11 +4,12 @@ """Parse CLDR data for QTimeZone use with MS-Windows Script to parse the CLDR common/supplemental/windowsZones.xml file and -encode for use in QTimeZone. See ``./cldr2qlocalexml.py`` for where -to get the CLDR data. Pass its root directory as first parameter to -this script and the qtbase root directory as second parameter. It -shall update qtbase's src/corelib/time/qtimezoneprivate_data_p.h ready -for use. +prepare its data for use in QTimeZone. See ``./cldr2qlocalexml.py`` for +where to get the CLDR data. Pass its root directory as first parameter +to this script. You can optionally pass the qtbase root directory as +second parameter; it defaults to the root of the checkout containing +this script. This script updates qtbase's +src/corelib/time/qtimezoneprivate_data_p.h with the new data. """ import datetime @@ -16,7 +17,7 @@ from pathlib import Path import textwrap import argparse -from localetools import unicode2hex, wrap_list, Error, SourceFileEditor +from localetools import unicode2hex, wrap_list, Error, SourceFileEditor, qtbase_root from cldr import CldrAccess ### Data that may need updates in response to new entries in the CLDR file ### @@ -310,7 +311,9 @@ def main(out, err): parser = argparse.ArgumentParser( description="Update Qt's CLDR-derived timezone data.") parser.add_argument('cldr_path', help='path to the root of the CLDR tree') - parser.add_argument('qtbase_path', help='path to the root of the qtbase source tree') + parser.add_argument('qtbase_path', + help='path to the root of the qtbase source tree', + nargs='?', default=qtbase_root) args = parser.parse_args() diff --git a/util/locale_database/localetools.py b/util/locale_database/localetools.py index b50f5a8ee3..a33ace4eb1 100644 --- a/util/locale_database/localetools.py +++ b/util/locale_database/localetools.py @@ -16,6 +16,9 @@ from contextlib import ExitStack, contextmanager from pathlib import Path from tempfile import NamedTemporaryFile +qtbase_root = Path(__file__).parents[2] +assert qtbase_root.name == 'qtbase' + class Error (Exception): def __init__(self, msg, *args): super().__init__(msg, *args) diff --git a/util/locale_database/qlocalexml2cpp.py b/util/locale_database/qlocalexml2cpp.py index a859fc1da1..3c8fb84abb 100755 --- a/util/locale_database/qlocalexml2cpp.py +++ b/util/locale_database/qlocalexml2cpp.py @@ -4,9 +4,10 @@ """Script to generate C++ code from CLDR data in QLocaleXML form See ``cldr2qlocalexml.py`` for how to generate the QLocaleXML data itself. -Pass the output file from that as first parameter to this script; pass -the ISO 639-3 data file as second parameter; pass the root of the qtbase -check-out as third parameter. +Pass the output file from that as first parameter to this script; pass the ISO +639-3 data file as second parameter. You can optionally pass the root of the +qtbase check-out as third parameter; it defaults to the root of the qtbase +check-out containing this script. The ISO 639-3 data file can be downloaded from the SIL website: @@ -19,7 +20,7 @@ from pathlib import Path from typing import Optional from qlocalexml import QLocaleXmlReader -from localetools import unicode2hex, wrap_list, Error, Transcriber, SourceFileEditor +from localetools import unicode2hex, wrap_list, Error, Transcriber, SourceFileEditor, qtbase_root from iso639_3 import LanguageCodeData class LocaleKeySorter: @@ -521,8 +522,8 @@ class LocaleHeaderWriter (SourceFileEditor): def main(out, err): - # map { CLDR name: Qt file name } calendars_map = { + # CLDR name: Qt file name fragment 'gregorian': 'roman', 'persian': 'jalali', 'islamic': 'hijri', @@ -537,7 +538,8 @@ def main(out, err): metavar='input-file.xml') parser.add_argument('iso_path', help='path to the ISO 639-3 data file', metavar='iso-639-3.tab') - parser.add_argument('qtbase_path', help='path to the root of the qtbase source tree') + parser.add_argument('qtbase_path', help='path to the root of the qtbase source tree', + nargs='?', default=qtbase_root) parser.add_argument('--calendars', help='select calendars to emit data for', nargs='+', metavar='CALENDAR', choices=all_calendars, default=all_calendars) |