summaryrefslogtreecommitdiffstats
path: root/util/local_database/xpathlite.py
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-03-24 09:37:54 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-03-24 09:37:54 (GMT)
commitf1a7f339109ee72059aa135381defeaf6f564977 (patch)
tree6a5e8e28849c025efc58096bd57eb1ece7382fc6 /util/local_database/xpathlite.py
parentcea4ae150bef0f24b0e8385d47b06a9f6b8197c3 (diff)
parent52dc52dffb80f3ffd321156639564b524263810a (diff)
downloadQt-f1a7f339109ee72059aa135381defeaf6f564977.zip
Qt-f1a7f339109ee72059aa135381defeaf6f564977.tar.gz
Qt-f1a7f339109ee72059aa135381defeaf6f564977.tar.bz2
Merge remote branch 'earth-team/master-i18n' into 4.8-earth
Conflicts: src/corelib/tools/tools.pri
Diffstat (limited to 'util/local_database/xpathlite.py')
-rw-r--r--util/local_database/xpathlite.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/util/local_database/xpathlite.py b/util/local_database/xpathlite.py
index 95e6711..502d85d 100644
--- a/util/local_database/xpathlite.py
+++ b/util/local_database/xpathlite.py
@@ -87,6 +87,48 @@ def findChild(parent, tag_name, arg_name=None, arg_value=None, draft=None):
return node
return False
+def findTagsInFile(file, path):
+ doc = False
+ if doc_cache.has_key(file):
+ doc = doc_cache[file]
+ else:
+ doc = xml.dom.minidom.parse(file)
+ doc_cache[file] = doc
+
+ elt = doc.documentElement
+ tag_spec_list = path.split("/")
+ last_entry = 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].split("=")
+ if len(arg_value) == 2:
+ arg_name = arg_value[0]
+ arg_value = arg_value[1]
+ else:
+ arg_value = arg_value[0]
+ elt = findChild(elt, tag_name, arg_name, arg_value)
+ if not elt:
+ return None
+ ret = []
+ if elt.childNodes:
+ for node in elt.childNodes:
+ if node.attributes:
+ element = [node.nodeName, None]
+ element[1] = node.attributes.items()
+ ret.append(element)
+ else:
+ if elt.attributes:
+ element = [elt.nodeName, None]
+ element[1] = elt.attributes.items()
+ ret.append(element)
+ return ret
+
def _findEntryInFile(file, path, draft=None, attribute=None):
doc = False
if doc_cache.has_key(file):