diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-02-19 17:18:28 +0100 |
---|---|---|
committer | Edward Welbourne <eddy@chaos.org.uk> | 2020-04-02 19:42:40 +0100 |
commit | c3dea1ffca7e46319daed5b44895c6e09f51f3ea (patch) | |
tree | 141da0f6c8cacc0d13459d06ff921594b763b954 /util/locale_database/cldr2qtimezone.py | |
parent | 4d9f1a87de7a6e50e89f96836bc2f0cf6e229dda (diff) |
Move some shared code to a localetools module
The time-zone script was importing two functions from the locale data
generation script. Move them to a separate module, to which I'll
shortly add some more shared utilities. Cleaned up some imports in the
process.
Combined qlocalexml2cpp's and xpathlit's error classes into a new
Error class in the new module and made it a bit more like a proper
python error class.
Task-number: QTBUG-81344
Change-Id: Idbe0139ba9aaa2f823b8f7216dee1d2539c18b75
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'util/locale_database/cldr2qtimezone.py')
-rwxr-xr-x | util/locale_database/cldr2qtimezone.py | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/util/locale_database/cldr2qtimezone.py b/util/locale_database/cldr2qtimezone.py index 4c3609056d..7816abc9e1 100755 --- a/util/locale_database/cldr2qtimezone.py +++ b/util/locale_database/cldr2qtimezone.py @@ -54,20 +54,14 @@ The XML structure is as follows: import os import sys +import re import datetime import tempfile -import enumdata -import xpathlite -from xpathlite import DraftResolution -import re -import qlocalexml2cpp -findAlias = xpathlite.findAlias -findEntry = xpathlite.findEntry -findEntryInFile = xpathlite._findEntryInFile -findTagsInFile = xpathlite.findTagsInFile -unicode2hex = qlocalexml2cpp.unicode2hex -wrap_list = qlocalexml2cpp.wrap_list +import enumdata +from localetools import unicode2hex, wrap_list, Error +from xpathlite import DraftResolution, findAlias, findEntry, findTagsInFile, \ + _findEntryInFile as findEntryInFile class ByteArrayData: def __init__(self): @@ -343,13 +337,13 @@ if mapTimezones: else: data['countryId'] = enumdata.countryCodeToId(data['countryCode']) if data['countryId'] < 0: - raise xpathlite.Error("Unknown Country Code \"%s\"" % data['countryCode']) + raise Error('Unknown Country Code "{}"'.format(data['countryCode'])) data['country'] = enumdata.country_list[data['countryId']][0] windowsIdDict[data['windowsKey'], data['countryId']] = data if badZones: sys.stderr.write('\n\t'.join(["\nUnknown Windows ID, please add:"] + sorted(badZones)) + "\nto the windowIdList in cldr2qtimezone.py\n\n") - raise xpathlite.Error("Unknown Windows IDs") + raise Error('Unknown Windows IDs') print "Input file parsed, now writing data" |