diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2017-05-12 11:59:18 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2017-06-08 13:37:06 +0000 |
commit | 08cfd02312d21391c956b8bf50ab7d6caa0d8082 (patch) | |
tree | e8eafe2ba54f0389605244e5018410f88b9f384c /util/local_database/cldr2qtimezone.py | |
parent | 72900b3d88dc326ace5b091d2ba8cea5ffb28a90 (diff) |
Use python more competently in CLDR/qLocaleXML scripts
Make the python2 dependency explicit (sooner or later, python3 shall
be the default /bin/env python), make time-zone script executable (it
had a shebang). Use triple-quoted strings, or single quotes, to avoid
extra backslashes, remove some simply spurious backslashes. Use
generators rather than map or filter with lambdas and iterate rather
than duplicating code. Clarify some comments.
Regenerated headers: this upates the date of generation, cuts back a
double-blank-line to single and skips a spurious trailing
comma-newline on an array's data.
Change-Id: I54439f0dec132865991fe5147d509cea0f9419a0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'util/local_database/cldr2qtimezone.py')
-rwxr-xr-x[-rw-r--r--] | util/local_database/cldr2qtimezone.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/util/local_database/cldr2qtimezone.py b/util/local_database/cldr2qtimezone.py index bf30e39910..72abb3c355 100644..100755 --- a/util/local_database/cldr2qtimezone.py +++ b/util/local_database/cldr2qtimezone.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 ############################################################################# ## ## Copyright (C) 2016 The Qt Company Ltd. @@ -335,15 +335,17 @@ while s and s != GENERATED_BLOCK_START: # Write out generated block start tag and warning newTempFile.write(GENERATED_BLOCK_START) -newTempFile.write("\n\ -/*\n\ - This part of the file was generated on %s from the\n\ - Common Locale Data Repository v%s supplemental/windowsZones.xml file %s\n\ -\n\ - http://www.unicode.org/cldr/\n\ -\n\ - Do not change this data, only generate it using cldr2qtimezone.py.\n\ -*/\n\n" % (str(datetime.date.today()), cldr_version, versionNumber) ) +newTempFile.write(""" +/* + This part of the file was generated on %s from the + Common Locale Data Repository v%s supplemental/windowsZones.xml file %s + + http://www.unicode.org/cldr/ + + Do not change this data, only generate it using cldr2qtimezone.py. +*/ + +""" % (str(datetime.date.today()), cldr_version, versionNumber) ) windowsIdData = ByteArrayData() ianaIdData = ByteArrayData() @@ -353,7 +355,7 @@ newTempFile.write("// Windows ID Key, Country Enum, IANA ID Index\n") newTempFile.write("static const QZoneData zoneDataTable[] = {\n") for index in windowsIdDict: data = windowsIdDict[index] - newTempFile.write(" { %6d,%6d,%6d }, // %s / %s\n" \ + newTempFile.write(" { %6d,%6d,%6d }, // %s / %s\n" % (data['windowsKey'], data['countryId'], ianaIdData.append(data['ianaList']), @@ -368,7 +370,7 @@ print "Done Zone Data" newTempFile.write("// Windows ID Key, Windows ID Index, IANA ID Index, UTC Offset\n") newTempFile.write("static const QWindowsData windowsDataTable[] = {\n") for windowsKey in windowsIdList: - newTempFile.write(" { %6d,%6d,%6d,%6d }, // %s\n" \ + newTempFile.write(" { %6d,%6d,%6d,%6d }, // %s\n" % (windowsKey, windowsIdData.append(windowsIdList[windowsKey][0]), ianaIdData.append(defaultDict[windowsKey]), @@ -384,7 +386,7 @@ newTempFile.write("// IANA ID Index, UTC Offset\n") newTempFile.write("static const QUtcData utcDataTable[] = {\n") for index in utcIdList: data = utcIdList[index] - newTempFile.write(" { %6d,%6d }, // %s\n" \ + newTempFile.write(" { %6d,%6d }, // %s\n" % (ianaIdData.append(data[0]), data[1], data[0])) |