Move LocaleScanner's INHERIT check from find upstream to __find
When digesting CLDR v44.1's github form, some data (e.g. pt_BR's language endonym) were None that had perfectly sensible values in the zip-file form. Letting __find() yield INHERIT entries lead to find() sometimes returning None, where __find() should have tried harder or raised an Error. This further amends commit bcdd51cfae24731a73d008add23d3c1e85bbd8d0 (after commit 0f770b0b34bcb5fa0a598b2ff76fe215fbc25f5c isolated its magic value). Pick-to: 6.7 Task-number: QTBUG-115158 Change-Id: I1af92a687cd50b8fd026c25f068c804a3516ef95 Reviewed-by: Mate Barany <mate.barany@qt.io>
This commit is contained in:
parent
7f447adcd8
commit
43cb4136a9
@ -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:
|
||||
@ -432,6 +430,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 +459,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,6 +471,15 @@ 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')
|
||||
|
Loading…
x
Reference in New Issue
Block a user