summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2017-05-31 19:34:09 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2017-06-09 08:24:22 +0000
commitad1cec5a5eeebbd7b2c657e4e2aff913815344e9 (patch)
treea405d26516f1bfd43f37a6ce7ba7dd95a90f5230 /util
parent03a1675eac4baf8c7a6e0602102bbafa3176771c (diff)
downloadqtbase-ad1cec5a5eeebbd7b2c657e4e2aff913815344e9.tar.gz
Simplify cldr2qlocalexml.integrateWeekData()
It had a separate variable for each of three lists for each day of the week; and used each list only once. Iterate the days of the week for each lookup, discarding it once used. Change-Id: I32c8bd5bfcbb99f0a8697d374e63112761f18dbb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-xutil/local_database/cldr2qlocalexml.py78
1 files changed, 13 insertions, 65 deletions
diff --git a/util/local_database/cldr2qlocalexml.py b/util/local_database/cldr2qlocalexml.py
index 0e61af5610..2f68b69a9f 100755
--- a/util/local_database/cldr2qlocalexml.py
+++ b/util/local_database/cldr2qlocalexml.py
@@ -322,77 +322,25 @@ def usage():
def integrateWeekData(filePath):
if not filePath.endswith(".xml"):
return {}
- monFirstDayIn = findEntryInFile(filePath, "weekData/firstDay[day=mon]", attribute="territories")[0].split(" ")
- tueFirstDayIn = findEntryInFile(filePath, "weekData/firstDay[day=tue]", attribute="territories")[0].split(" ")
- wedFirstDayIn = findEntryInFile(filePath, "weekData/firstDay[day=wed]", attribute="territories")[0].split(" ")
- thuFirstDayIn = findEntryInFile(filePath, "weekData/firstDay[day=thu]", attribute="territories")[0].split(" ")
- friFirstDayIn = findEntryInFile(filePath, "weekData/firstDay[day=fri]", attribute="territories")[0].split(" ")
- satFirstDayIn = findEntryInFile(filePath, "weekData/firstDay[day=sat]", attribute="territories")[0].split(" ")
- sunFirstDayIn = findEntryInFile(filePath, "weekData/firstDay[day=sun]", attribute="territories")[0].split(" ")
-
- monWeekendStart = findEntryInFile(filePath, "weekData/weekendStart[day=mon]", attribute="territories")[0].split(" ")
- tueWeekendStart = findEntryInFile(filePath, "weekData/weekendStart[day=tue]", attribute="territories")[0].split(" ")
- wedWeekendStart = findEntryInFile(filePath, "weekData/weekendStart[day=wed]", attribute="territories")[0].split(" ")
- thuWeekendStart = findEntryInFile(filePath, "weekData/weekendStart[day=thu]", attribute="territories")[0].split(" ")
- friWeekendStart = findEntryInFile(filePath, "weekData/weekendStart[day=fri]", attribute="territories")[0].split(" ")
- satWeekendStart = findEntryInFile(filePath, "weekData/weekendStart[day=sat]", attribute="territories")[0].split(" ")
- sunWeekendStart = findEntryInFile(filePath, "weekData/weekendStart[day=sun]", attribute="territories")[0].split(" ")
-
- monWeekendEnd = findEntryInFile(filePath, "weekData/weekendEnd[day=mon]", attribute="territories")[0].split(" ")
- tueWeekendEnd = findEntryInFile(filePath, "weekData/weekendEnd[day=tue]", attribute="territories")[0].split(" ")
- wedWeekendEnd = findEntryInFile(filePath, "weekData/weekendEnd[day=wed]", attribute="territories")[0].split(" ")
- thuWeekendEnd = findEntryInFile(filePath, "weekData/weekendEnd[day=thu]", attribute="territories")[0].split(" ")
- friWeekendEnd = findEntryInFile(filePath, "weekData/weekendEnd[day=fri]", attribute="territories")[0].split(" ")
- satWeekendEnd = findEntryInFile(filePath, "weekData/weekendEnd[day=sat]", attribute="territories")[0].split(" ")
- sunWeekendEnd = findEntryInFile(filePath, "weekData/weekendEnd[day=sun]", attribute="territories")[0].split(" ")
+
+ def lookup(key):
+ return findEntryInFile(filePath, key, attribute='territories')[0].split()
+ days = ('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun')
firstDayByCountryCode = {}
- for countryCode in monFirstDayIn:
- firstDayByCountryCode[countryCode] = "mon"
- for countryCode in tueFirstDayIn:
- firstDayByCountryCode[countryCode] = "tue"
- for countryCode in wedFirstDayIn:
- firstDayByCountryCode[countryCode] = "wed"
- for countryCode in thuFirstDayIn:
- firstDayByCountryCode[countryCode] = "thu"
- for countryCode in friFirstDayIn:
- firstDayByCountryCode[countryCode] = "fri"
- for countryCode in satFirstDayIn:
- firstDayByCountryCode[countryCode] = "sat"
- for countryCode in sunFirstDayIn:
- firstDayByCountryCode[countryCode] = "sun"
+ for day in days:
+ for countryCode in lookup('weekData/firstDay[day=%s]' % day):
+ firstDayByCountryCode[countryCode] = day
weekendStartByCountryCode = {}
- for countryCode in monWeekendStart:
- weekendStartByCountryCode[countryCode] = "mon"
- for countryCode in tueWeekendStart:
- weekendStartByCountryCode[countryCode] = "tue"
- for countryCode in wedWeekendStart:
- weekendStartByCountryCode[countryCode] = "wed"
- for countryCode in thuWeekendStart:
- weekendStartByCountryCode[countryCode] = "thu"
- for countryCode in friWeekendStart:
- weekendStartByCountryCode[countryCode] = "fri"
- for countryCode in satWeekendStart:
- weekendStartByCountryCode[countryCode] = "sat"
- for countryCode in sunWeekendStart:
- weekendStartByCountryCode[countryCode] = "sun"
+ for day in days:
+ for countryCode in lookup('weekData/weekendStart[day=%s]' % day):
+ weekendStartByCountryCode[countryCode] = day
weekendEndByCountryCode = {}
- for countryCode in monWeekendEnd:
- weekendEndByCountryCode[countryCode] = "mon"
- for countryCode in tueWeekendEnd:
- weekendEndByCountryCode[countryCode] = "tue"
- for countryCode in wedWeekendEnd:
- weekendEndByCountryCode[countryCode] = "wed"
- for countryCode in thuWeekendEnd:
- weekendEndByCountryCode[countryCode] = "thu"
- for countryCode in friWeekendEnd:
- weekendEndByCountryCode[countryCode] = "fri"
- for countryCode in satWeekendEnd:
- weekendEndByCountryCode[countryCode] = "sat"
- for countryCode in sunWeekendEnd:
- weekendEndByCountryCode[countryCode] = "sun"
+ for day in days:
+ for countryCode in lookup('weekData/weekendEnd[day=%s]' % day):
+ weekendEndByCountryCode[countryCode] = day
for (key, locale) in locale_database.iteritems():
countryCode = locale.country_code