From 40ed226e53fddc2a436233149feea6ca2d0c5740 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 14 Nov 2012 17:00:30 +0200 Subject: Misc fixes to the QLocale data parser/generator Change-Id: I01589eae4e48bc1f484d54277de8f18262ca8f31 Reviewed-by: Lars Knoll --- util/local_database/cldr2qlocalexml.py | 6 +++--- util/local_database/enumdata.py | 10 +++++----- util/local_database/qlocalexml2cpp.py | 22 +++------------------- util/local_database/xpathlite.py | 12 ++++++++---- 4 files changed, 19 insertions(+), 31 deletions(-) (limited to 'util/local_database') diff --git a/util/local_database/cldr2qlocalexml.py b/util/local_database/cldr2qlocalexml.py index e0bab604bb..e5accece74 100755 --- a/util/local_database/cldr2qlocalexml.py +++ b/util/local_database/cldr2qlocalexml.py @@ -136,13 +136,13 @@ def generateLocaleInfo(path): language_id = enumdata.languageCodeToId(language_code) if language_id == -1: - sys.stderr.write("unnknown language code \"" + language_code + "\"\n") + sys.stderr.write("unknown language code \"" + language_code + "\"\n") return {} language = enumdata.language_list[language_id][0] script_id = enumdata.scriptCodeToId(script_code) if script_code == -1: - sys.stderr.write("unnknown script code \"" + script_code + "\"\n") + sys.stderr.write("unknown script code \"" + script_code + "\"\n") return {} script = "AnyScript" if script_id != -1: @@ -153,7 +153,7 @@ def generateLocaleInfo(path): if country_id != -1: country = enumdata.country_list[country_id][0] if country == "": - sys.stderr.write("unnknown country code \"" + country_code + "\"\n") + sys.stderr.write("unknown country code \"" + country_code + "\"\n") return {} # So we say we accept only those values that have "contributed" or diff --git a/util/local_database/enumdata.py b/util/local_database/enumdata.py index 95f84d072e..78fc4d083e 100644 --- a/util/local_database/enumdata.py +++ b/util/local_database/enumdata.py @@ -40,7 +40,7 @@ ## ############################################################################# -# langugae_list and country_list reflect the current values of enums in qlocale.h +# language_list and country_list reflect the current values of enums in qlocale.h # If new xml language files are available in CLDR, these languages and countries # need to be *appended* to this list. @@ -126,7 +126,7 @@ language_list = { 78 : [ "Maltese", "mt" ], 79 : [ "Maori", "mi" ], 80 : [ "Marathi", "mr" ], - 81 : [ "Moldavian", "mo" ], + 81 : [ "Moldavian", "mo" ], # deprecated (alias to "ro_MD") 82 : [ "Mongolian", "mn" ], 83 : [ "Nauru", "na" ], 84 : [ "Nepali", "ne" ], @@ -146,7 +146,7 @@ language_list = { 98 : [ "Sangho", "sg" ], 99 : [ "Sanskrit", "sa" ], 100 : [ "Serbian", "sr" ], - 101 : [ "SerboCroatian", "sh" ], + 101 : [ "SerboCroatian", "sh" ], # legacy (alias to "sr_Latn") 102 : [ "Sesotho", "st" ], 103 : [ "Setswana", "tn" ], 104 : [ "Shona", "sn" ], @@ -160,7 +160,7 @@ language_list = { 112 : [ "Sundanese", "su" ], 113 : [ "Swahili", "sw" ], 114 : [ "Swedish", "sv" ], - 115 : [ "Tagalog", "tl" ], + 115 : [ "Tagalog", "tl" ], # legacy (alias to "fil") 116 : [ "Tajik", "tg" ], 117 : [ "Tamil", "ta" ], 118 : [ "Tatar", "tt" ], @@ -172,7 +172,7 @@ language_list = { 124 : [ "Tsonga", "ts" ], 125 : [ "Turkish", "tr" ], 126 : [ "Turkmen", "tk" ], - 127 : [ "Twi", "tw" ], + 127 : [ "Twi", "tw" ], # should be an alias to Akan 128 : [ "Uigur", "ug" ], 129 : [ "Ukrainian", "uk" ], 130 : [ "Urdu", "ur" ], diff --git a/util/local_database/qlocalexml2cpp.py b/util/local_database/qlocalexml2cpp.py index 5ea1eba2c8..cb243652fc 100755 --- a/util/local_database/qlocalexml2cpp.py +++ b/util/local_database/qlocalexml2cpp.py @@ -52,14 +52,6 @@ class Error: def __str__(self): return self.msg -def check_static_char_array_length(name, array): - # some compilers like VC6 doesn't allow static arrays more than 64K bytes size. - size = reduce(lambda x, y: x+len(escapedString(y)), array, 0) - if size > 65535: - print "\n\n\n#error Array %s is too long! " % name - sys.stderr.write("\n\n\nERROR: the content of the array '%s' is too long: %d > 65535 " % (name, size)) - sys.exit(1) - def wrap_list(lst): def split(lst, size): for i in range(len(lst)/size+1): @@ -580,7 +572,6 @@ def main(): data_temp_file.write("\n") # List patterns data - #check_static_char_array_length("list_pattern_part", list_pattern_part_data.data) data_temp_file.write("static const ushort list_pattern_part_data[] = {\n") data_temp_file.write(wrap_list(list_pattern_part_data.data)) data_temp_file.write("\n};\n") @@ -588,7 +579,6 @@ def main(): data_temp_file.write("\n") # Date format data - #check_static_char_array_length("date_format", date_format_data.data) data_temp_file.write("static const ushort date_format_data[] = {\n") data_temp_file.write(wrap_list(date_format_data.data)) data_temp_file.write("\n};\n") @@ -596,7 +586,6 @@ def main(): data_temp_file.write("\n") # Time format data - #check_static_char_array_length("time_format", time_format_data.data) data_temp_file.write("static const ushort time_format_data[] = {\n") data_temp_file.write(wrap_list(time_format_data.data)) data_temp_file.write("\n};\n") @@ -604,7 +593,6 @@ def main(): data_temp_file.write("\n") # Months data - #check_static_char_array_length("months", months_data.data) data_temp_file.write("static const ushort months_data[] = {\n") data_temp_file.write(wrap_list(months_data.data)) data_temp_file.write("\n};\n") @@ -612,7 +600,6 @@ def main(): data_temp_file.write("\n") # Days data - #check_static_char_array_length("days", days_data.data) data_temp_file.write("static const ushort days_data[] = {\n") data_temp_file.write(wrap_list(days_data.data)) data_temp_file.write("\n};\n") @@ -620,7 +607,6 @@ def main(): data_temp_file.write("\n") # AM data - #check_static_char_array_length("am", am_data.data) data_temp_file.write("static const ushort am_data[] = {\n") data_temp_file.write(wrap_list(am_data.data)) data_temp_file.write("\n};\n") @@ -628,7 +614,6 @@ def main(): data_temp_file.write("\n") # PM data - #check_static_char_array_length("pm", am_data.data) data_temp_file.write("static const ushort pm_data[] = {\n") data_temp_file.write(wrap_list(pm_data.data)) data_temp_file.write("\n};\n") @@ -636,7 +621,6 @@ def main(): data_temp_file.write("\n") # Currency symbol data - #check_static_char_array_length("currency_symbol", currency_symbol_data.data) data_temp_file.write("static const ushort currency_symbol_data[] = {\n") data_temp_file.write(wrap_list(currency_symbol_data.data)) data_temp_file.write("\n};\n") @@ -644,7 +628,6 @@ def main(): data_temp_file.write("\n") # Currency display name data - #check_static_char_array_length("currency_display_name", currency_display_name_data.data) data_temp_file.write("static const ushort currency_display_name_data[] = {\n") data_temp_file.write(wrap_list(currency_display_name_data.data)) data_temp_file.write("\n};\n") @@ -652,13 +635,11 @@ def main(): data_temp_file.write("\n") # Currency format data - #check_static_char_array_length("currency_format", currency_format_data.data) data_temp_file.write("static const ushort currency_format_data[] = {\n") data_temp_file.write(wrap_list(currency_format_data.data)) data_temp_file.write("\n};\n") # Endonyms data - #check_static_char_array_length("endonyms", endonyms_data.data) data_temp_file.write("static const ushort endonyms_data[] = {\n") data_temp_file.write(wrap_list(endonyms_data.data)) data_temp_file.write("\n};\n") @@ -783,6 +764,7 @@ def main(): data_temp_file.close() qlocaledata_file.close() + os.remove(qtsrcdir + "/src/corelib/tools/qlocale_data_p.h") os.rename(data_temp_file_path, qtsrcdir + "/src/corelib/tools/qlocale_data_p.h") # qlocale.h @@ -844,6 +826,7 @@ def main(): qlocaleh_temp_file.close() qlocaleh_file.close() + os.remove(qtsrcdir + "/src/corelib/tools/qlocale.h") os.rename(qlocaleh_temp_file_path, qtsrcdir + "/src/corelib/tools/qlocale.h") # qlocale.qdoc @@ -862,6 +845,7 @@ def main(): qlocaleqdoc_temp_file.close() qlocaleqdoc_file.close() + os.remove(qtsrcdir + "/src/corelib/tools/qlocale.qdoc") os.rename(qlocaleqdoc_temp_file_path, qtsrcdir + "/src/corelib/tools/qlocale.qdoc") if __name__ == "__main__": diff --git a/util/local_database/xpathlite.py b/util/local_database/xpathlite.py index a9e309629e..5bea6ce63a 100644 --- a/util/local_database/xpathlite.py +++ b/util/local_database/xpathlite.py @@ -181,9 +181,13 @@ def _findEntryInFile(file, path, draft=None, attribute=None): return (elt.firstChild.nodeValue, None) def findAlias(file): - if not doc_cache.has_key(file): - return False - doc = doc_cache[file] + doc = False + if doc_cache.has_key(file): + doc = doc_cache[file] + else: + doc = xml.dom.minidom.parse(file) + doc_cache[file] = doc + alias_elt = findChild(doc.documentElement, "alias") if not alias_elt: return False @@ -242,7 +246,7 @@ def findEntry(base, path, draft=None, attribute=None): if result: return result if not aliaspath: - raise Error("findEntry: fatal error: %s: did not found key %s" % (filename, path)) + raise Error("findEntry: fatal error: %s: can not find key %s" % (filename, path)) path = aliaspath return result -- cgit v1.2.3