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 615047e98f
)
This commit is contained in:
parent
a5756053b3
commit
afe038bb0e
@ -708,7 +708,8 @@ enumdata.py (keeping the old name as an alias):
|
|||||||
def __parentLocale(self, cache = {}):
|
def __parentLocale(self, cache = {}):
|
||||||
# see http://www.unicode.org/reports/tr35/#Parent_Locales
|
# see http://www.unicode.org/reports/tr35/#Parent_Locales
|
||||||
if not cache:
|
if not cache:
|
||||||
for tag, attrs in self.__supplementalData.find('parentLocales'):
|
for tag, attrs in self.__supplementalData.find('parentLocales',
|
||||||
|
('component',)):
|
||||||
parent = attrs.get('parent', '')
|
parent = attrs.get('parent', '')
|
||||||
for child in attrs['locales'].split():
|
for child in attrs['locales'].split():
|
||||||
cache[child] = parent
|
cache[child] = parent
|
||||||
|
@ -166,10 +166,23 @@ class XmlScanner (object):
|
|||||||
return elts
|
return elts
|
||||||
|
|
||||||
class Supplement (XmlScanner):
|
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)
|
elts = self.findNodes(xpath)
|
||||||
for elt in _iterateEach(e.dom.childNodes if e.dom.childNodes else (e.dom,)
|
for elt in _iterateEach(e.dom.childNodes or (e.dom,)
|
||||||
for e in elts):
|
for e in elts
|
||||||
|
if not any(a in e.dom.attributes
|
||||||
|
for a in exclude)):
|
||||||
if elt.attributes:
|
if elt.attributes:
|
||||||
yield (elt.nodeName,
|
yield (elt.nodeName,
|
||||||
dict((k, v if isinstance(v, str) else v.nodeValue)
|
dict((k, v if isinstance(v, str) else v.nodeValue)
|
||||||
|
Loading…
Reference in New Issue
Block a user