summaryrefslogtreecommitdiffstats
path: root/util/local_database/xpathlite.py
diff options
context:
space:
mode:
Diffstat (limited to 'util/local_database/xpathlite.py')
-rw-r--r--util/local_database/xpathlite.py74
1 files changed, 31 insertions, 43 deletions
diff --git a/util/local_database/xpathlite.py b/util/local_database/xpathlite.py
index b8205b453e..39402058c6 100644
--- a/util/local_database/xpathlite.py
+++ b/util/local_database/xpathlite.py
@@ -1,41 +1,33 @@
#!/usr/bin/env python
#############################################################################
##
-## Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-## Contact: http://www.qt-project.org/legal
+## Copyright (C) 2015 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
##
## This file is part of the test suite of the Qt Toolkit.
##
-## $QT_BEGIN_LICENSE:LGPL$
+## $QT_BEGIN_LICENSE:LGPL21$
## Commercial License Usage
## Licensees holding valid commercial Qt licenses may use this file in
## accordance with the commercial license agreement provided with the
## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and Digia. For licensing terms and
-## conditions see http://qt.digia.com/licensing. For further information
-## use the contact form at http://qt.digia.com/contact-us.
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see http://www.qt.io/terms-conditions. For further
+## information use the contact form at http://www.qt.io/contact-us.
##
## GNU Lesser General Public License Usage
## Alternatively, this file may be used under the terms of the GNU Lesser
-## General Public License version 2.1 as published by the Free Software
-## Foundation and appearing in the file LICENSE.LGPL included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU Lesser General Public License version 2.1 requirements
-## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+## General Public License version 2.1 or version 3 as published by the Free
+## Software Foundation and appearing in the file LICENSE.LGPLv21 and
+## LICENSE.LGPLv3 included in the packaging of this file. Please review the
+## following information to ensure the GNU Lesser General Public License
+## requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
##
-## In addition, as a special exception, Digia gives you certain additional
-## rights. These rights are described in the Digia Qt LGPL Exception
+## As a special exception, The Qt Company gives you certain additional
+## rights. These rights are described in The Qt Company LGPL Exception
## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3.0 as published by the Free Software
-## Foundation and appearing in the file LICENSE.GPL included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU General Public License version 3.0 requirements will be
-## met: http://www.gnu.org/copyleft/gpl.html.
-##
-##
## $QT_END_LICENSE$
##
#############################################################################
@@ -44,8 +36,6 @@ import sys
import os
import xml.dom.minidom
-doc_cache = {}
-
class DraftResolution:
# See http://www.unicode.org/cldr/process.html for description
unconfirmed = 'unconfirmed'
@@ -64,6 +54,12 @@ class Error:
def __str__(self):
return self.msg
+doc_cache = {}
+def parseDoc(file):
+ if not doc_cache.has_key(file):
+ doc_cache[file] = xml.dom.minidom.parse(file)
+ return doc_cache[file]
+
def findChild(parent, tag_name, arg_name=None, arg_value=None, draft=None):
for node in parent.childNodes:
if node.nodeType != node.ELEMENT_NODE:
@@ -88,12 +84,7 @@ def findChild(parent, tag_name, arg_name=None, arg_value=None, draft=None):
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
+ doc = parseDoc(file)
elt = doc.documentElement
tag_spec_list = path.split("/")
@@ -130,12 +121,7 @@ def findTagsInFile(file, path):
return ret
def _findEntryInFile(file, path, draft=None, attribute=None):
- doc = False
- if doc_cache.has_key(file):
- doc = doc_cache[file]
- else:
- doc = xml.dom.minidom.parse(file)
- doc_cache[file] = doc
+ doc = parseDoc(file)
elt = doc.documentElement
tag_spec_list = path.split("/")
@@ -185,12 +171,7 @@ def _findEntryInFile(file, path, draft=None, attribute=None):
return (None, None)
def findAlias(file):
- doc = False
- if doc_cache.has_key(file):
- doc = doc_cache[file]
- else:
- doc = xml.dom.minidom.parse(file)
- doc_cache[file] = doc
+ doc = parseDoc(file)
alias_elt = findChild(doc.documentElement, "alias")
if not alias_elt:
@@ -199,8 +180,12 @@ def findAlias(file):
return False
return alias_elt.attributes['source'].nodeValue
+lookup_chain_cache = {}
parent_locales = {}
def _fixedLookupChain(dirname, name):
+ if lookup_chain_cache.has_key(name):
+ return lookup_chain_cache[name]
+
# see http://www.unicode.org/reports/tr35/#Parent_Locales
if not parent_locales:
for ns in findTagsInFile(dirname + "/../supplemental/supplementalData.xml", "parentLocales"):
@@ -225,8 +210,11 @@ def _fixedLookupChain(dirname, name):
if parent_locale == u"root":
items = items[:i+1]
else:
- items = items[:i+1] + parent_locale.split() + items[i+1:]
+ items = items[:i+1] + _fixedLookupChain(dirname, parent_locale)
+ lookup_chain_cache[name] = items
return items
+
+ lookup_chain_cache[name] = items
return items
def _findEntry(base, path, draft=None, attribute=None):