summaryrefslogtreecommitdiffstats
path: root/util/locale_database/ldml.py
diff options
context:
space:
mode:
Diffstat (limited to 'util/locale_database/ldml.py')
-rw-r--r--util/locale_database/ldml.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/util/locale_database/ldml.py b/util/locale_database/ldml.py
index 3899c94109..219d1f7145 100644
--- a/util/locale_database/ldml.py
+++ b/util/locale_database/ldml.py
@@ -219,9 +219,7 @@ class LocaleScanner (object):
for elt in self.__find(xpath):
try:
if draft is None or elt.draft <= draft:
- value = elt.dom.firstChild.nodeValue
- if value != INHERIT:
- return value
+ return elt.dom.firstChild.nodeValue
except (AttributeError, KeyError):
pass
except Error as e:
@@ -360,6 +358,7 @@ class LocaleScanner (object):
def endonyms(self, language, script, territory, variant):
# TODO: take variant into account ?
+ # TODO: QTBUG-47892, support query for all combinations
for seq in ((language, script, territory),
(language, script), (language, territory), (language,)):
if not all(seq):
@@ -419,7 +418,7 @@ class LocaleScanner (object):
('long', 'format', 'wide'),
('short', 'format', 'abbreviated'),
('narrow', 'format', 'narrow'),
- ) # Used for month and day names
+ ) # Used for month and day names
def __find(self, xpath):
retries, foundNone = [ xpath.split('/') ], True
@@ -432,6 +431,7 @@ class LocaleScanner (object):
break
else: # Found matching elements
+ elts = tuple(self.__skipInheritors(elts))
if elts:
foundNone = False
# Possibly filter elts to prefer the least drafty ?
@@ -460,6 +460,7 @@ class LocaleScanner (object):
raise Error(f'All lack child {selector} for {sought} in {self.name}')
else: # Found matching elements
+ roots = tuple(self.__skipInheritors(roots))
if roots:
foundNone = False
for elt in roots:
@@ -471,12 +472,21 @@ class LocaleScanner (object):
sought += f' (for {xpath})'
raise Error(f'No {sought} in {self.name}')
+ @staticmethod
+ def __skipInheritors(elts):
+ for elt in elts:
+ try:
+ if elt.dom.firstChild.nodeValue != INHERIT:
+ yield elt
+ except (AttributeError, KeyError):
+ yield elt
+
def __currencyDisplayName(self, stem):
try:
return self.find(stem + 'displayName')
except Error:
pass
- for x in ('zero', 'one', 'two', 'few', 'many', 'other'):
+ for x in ('zero', 'one', 'two', 'few', 'many', 'other'):
try:
return self.find(f'{stem}displayName[count={x}]')
except Error: