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.5 Task-number: QTBUG-115158 Change-Id: I1af92a687cd50b8fd026c25f068c804a3516ef95 Reviewed-by: Mate Barany <mate.barany@qt.io> (cherry picked from commit 43cb4136a92331d1137ddd7453e7bb4ca130ecff) Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
This commit is contained in:
parent
a7338bd830
commit
249b8ff3ff
@ -207,9 +207,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:
|
||||
@ -420,6 +418,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 ?
|
||||
@ -448,6 +447,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:
|
||||
@ -459,6 +459,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