diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2010-03-19 15:15:45 +0100 |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2010-03-22 14:21:36 +0100 |
commit | 15d64b6e8c5ce98cb8c1061c007afe7f19751226 (patch) | |
tree | a60e41f10e104a66c398275510e0ceaebd8bc435 /util/local_database/xpathlite.py | |
parent | 44354dc9eebb1fa84529f965e92447b114eb881c (diff) | |
download | qt4-tools-15d64b6e8c5ce98cb8c1061c007afe7f19751226.tar.gz |
Improved CLDR parser.
Added support for "defaultNumberingSystem" element to get the right numeric
information (decimal point, group separator, zero digit etc).
Also fixed xpaths to the AM/PM text for CLDR 1.8.0
Reviewed-by: trustme
Diffstat (limited to 'util/local_database/xpathlite.py')
-rw-r--r-- | util/local_database/xpathlite.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/util/local_database/xpathlite.py b/util/local_database/xpathlite.py index 0f21a1910e..7d569f30b5 100644 --- a/util/local_database/xpathlite.py +++ b/util/local_database/xpathlite.py @@ -64,16 +64,16 @@ class Error: def __str__(self): return self.msg -def findChild(parent, tag_name, arg_value, draft=None): +def findChild(parent, tag_name, arg_name=None, arg_value=None, draft=None): for node in parent.childNodes: if node.nodeType != node.ELEMENT_NODE: continue if node.nodeName != tag_name: continue if arg_value: - if not node.attributes.has_key('type'): + if not node.attributes.has_key(arg_name): continue - if node.attributes['type'].nodeValue != arg_value: + if node.attributes[arg_name].nodeValue != arg_value: continue if draft: if not node.attributes.has_key('draft'): @@ -101,12 +101,18 @@ def _findEntryInFile(file, path, draft=None, attribute=None): for i in range(len(tag_spec_list)): tag_spec = tag_spec_list[i] tag_name = tag_spec + arg_name = 'type' arg_value = '' left_bracket = tag_spec.find('[') if left_bracket != -1: tag_name = tag_spec[:left_bracket] - arg_value = tag_spec[left_bracket+1:-1] - alias = findChild(elt, 'alias', None) + arg_value = tag_spec[left_bracket+1:-1].split("=") + if len(arg_value) == 2: + arg_name = arg_value[0] + arg_value = arg_value[1] + else: + arg_value = arg_value[0] + alias = findChild(elt, 'alias') if alias and alias.attributes['source'].nodeValue == 'locale': path = alias.attributes['path'].nodeValue aliaspath = tag_spec_list[:i] + path.split("/") @@ -123,7 +129,7 @@ def _findEntryInFile(file, path, draft=None, attribute=None): aliaspath = "/".join(aliaspath) # "locale" aliases are special - we need to start lookup from scratch return (None, aliaspath) - elt = findChild(elt, tag_name, arg_value, draft) + elt = findChild(elt, tag_name, arg_name, arg_value, draft) if not elt: return ("", None) if attribute is not None: @@ -136,7 +142,7 @@ def findAlias(file): if not doc_cache.has_key(file): return False doc = doc_cache[file] - alias_elt = findChild(doc.documentElement, "alias", "") + alias_elt = findChild(doc.documentElement, "alias") if not alias_elt: return False if not alias_elt.attributes.has_key('source'): |