summaryrefslogtreecommitdiffstats
path: root/util/locale_database/qlocalexml.py
diff options
context:
space:
mode:
authorIevgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>2021-07-05 17:45:26 +0200
committerIevgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>2021-07-15 17:06:53 +0200
commitb02d17c5c0f01a6c24cacaea2a3a41bfcc37490f (patch)
tree17f5694bb410a1bd3d70a31b5eb3720e49ad7e29 /util/locale_database/qlocalexml.py
parent973ca1fac680d8c593645058fae3fe7c84a7fa16 (diff)
Convert CLDR scripts to Python 3
The convertion is moslty done using 2to3 script with manual cleanup afterwards. Task-number: QTBUG-83488 Pick-to: 6.2 Change-Id: I4d33b04e7269c55a83ff2deb876a23a78a89f39d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'util/locale_database/qlocalexml.py')
-rw-r--r--util/locale_database/qlocalexml.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/util/locale_database/qlocalexml.py b/util/locale_database/qlocalexml.py
index 630794735f..7358e674f8 100644
--- a/util/locale_database/qlocalexml.py
+++ b/util/locale_database/qlocalexml.py
@@ -36,14 +36,14 @@ Provides classes:
Support:
Spacer -- provides control over indentation of the output.
"""
-from __future__ import print_function
+
from xml.sax.saxutils import escape
from localetools import Error
# Tools used by Locale:
def camel(seq):
- yield seq.next()
+ yield next(seq)
for word in seq:
yield word.capitalize()
@@ -58,7 +58,7 @@ def startCount(c, text): # strspn
"""First index in text where it doesn't have a character in c"""
assert text and text[0] in c
try:
- return (j for j, d in enumerate(text) if d not in c).next()
+ return next((j for j, d in enumerate(text) if d not in c))
except StopIteration:
return len(text)
@@ -166,7 +166,7 @@ class QLocaleXmlReader (object):
def languageIndices(self, locales):
index = 0
- for key, value in self.languages.iteritems():
+ for key, value in self.languages.items():
i, count = 0, locales.count(key)
if count > 0:
i = index
@@ -360,9 +360,7 @@ class QLocaleXmlWriter (object):
self.__openTag('locale')
self.__writeLocale(Locale.C(calendars), calendars)
self.__closeTag('locale')
- keys = locales.keys()
- keys.sort()
- for key in keys:
+ for key in sorted(locales.keys()):
self.__openTag('locale')
self.__writeLocale(locales[key], calendars)
self.__closeTag('locale')
@@ -403,7 +401,7 @@ class QLocaleXmlWriter (object):
def __enumTable(self, tag, table):
self.__openTag(tag + 'List')
- for key, value in table.iteritems():
+ for key, value in table.items():
self.__openTag(tag)
self.inTag('name', value[0])
self.inTag('id', key)
@@ -545,7 +543,7 @@ class Locale (object):
'_'.join((k, cal))
for k in self.propsMonthDay('months')
for cal in calendars):
- write(key, escape(get(key)).encode('utf-8'))
+ write(key, escape(get(key)))
write('groupSizes', ';'.join(str(x) for x in get('groupSizes')))
for key in ('currencyDigits', 'currencyRounding'):