summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2023-07-27 17:24:01 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2023-08-04 09:45:21 +0200
commitafe038bb0eefc1cc498b050d26ffacf1fedbac30 (patch)
treeb3cb30c0df7f331546449870801ff8f3f51e2dbf /util
parenta5756053b3463fe009e97e4fbf81eedeae5d277b (diff)
Ignore parentLocales nodes with component="..." attributes
From CLDR v43, "The parentLocale elements now have an optional component attribute, with a value of segmentations or collations. These should be used for inheritance for those respective elements." Since we aren't extracting collation or segmentation data for the present, omit these elements from the scan for parentLocale information. Task-number: QTBUG-111550 Change-Id: I42871929f539c1852471812801953f2fc8be0e8a Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> (cherry picked from commit 615047e98f1ef2a6d1d1d1830c74d1d02dcec336)
Diffstat (limited to 'util')
-rw-r--r--util/locale_database/cldr.py3
-rw-r--r--util/locale_database/ldml.py19
2 files changed, 18 insertions, 4 deletions
diff --git a/util/locale_database/cldr.py b/util/locale_database/cldr.py
index 91b46d6a01..78ed7a70a0 100644
--- a/util/locale_database/cldr.py
+++ b/util/locale_database/cldr.py
@@ -708,7 +708,8 @@ enumdata.py (keeping the old name as an alias):
def __parentLocale(self, cache = {}):
# see http://www.unicode.org/reports/tr35/#Parent_Locales
if not cache:
- for tag, attrs in self.__supplementalData.find('parentLocales'):
+ for tag, attrs in self.__supplementalData.find('parentLocales',
+ ('component',)):
parent = attrs.get('parent', '')
for child in attrs['locales'].split():
cache[child] = parent
diff --git a/util/locale_database/ldml.py b/util/locale_database/ldml.py
index f292235fb4..f0a8be520e 100644
--- a/util/locale_database/ldml.py
+++ b/util/locale_database/ldml.py
@@ -166,10 +166,23 @@ class XmlScanner (object):
return elts
class Supplement (XmlScanner):
- def find(self, xpath):
+ def find(self, xpath, exclude=()):
+ """Finds nodes by matching a specified xpath.
+
+ If exclude is passed, it should be a sequence of attribute names (its
+ default is empty). Any matches to the given xpath that also have any
+ attribute in this sequence will be excluded.
+
+ For each childless node matching the xpath, or child of a node matching
+ the xpath, this yields a twople (name, attrs) where name is the
+ nodeName and attrs is a dict mapping the node's attribute's names to
+ their values. For attribute values that are not simple strings, the
+ nodeValue of the attribute node is used."""
elts = self.findNodes(xpath)
- for elt in _iterateEach(e.dom.childNodes if e.dom.childNodes else (e.dom,)
- for e in elts):
+ for elt in _iterateEach(e.dom.childNodes or (e.dom,)
+ for e in elts
+ if not any(a in e.dom.attributes
+ for a in exclude)):
if elt.attributes:
yield (elt.nodeName,
dict((k, v if isinstance(v, str) else v.nodeValue)