summaryrefslogtreecommitdiffstats
path: root/util/locale_database/ldml.py
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-01 15:36:06 +0200
commit615047e98f1ef2a6d1d1d1830c74d1d02dcec336 (patch)
tree05aa4c384962c3d0925b23736344b218634ed761 /util/locale_database/ldml.py
parent37c5a9f20b9973a0f29c05965e243622f5596da0 (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>
Diffstat (limited to 'util/locale_database/ldml.py')
-rw-r--r--util/locale_database/ldml.py19
1 files changed, 16 insertions, 3 deletions
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)