diff scripts/import_cldr.py @ 345:64d340f76701

Update to CLDR 1.5.1, which split out the metazone mappings into a separate supplemental file.
author cmlenz
date Mon, 16 Jun 2008 12:24:04 +0000
parents bc22f5aef216
children 369300a7ebd3
line wrap: on
line diff
--- a/scripts/import_cldr.py
+++ b/scripts/import_cldr.py
@@ -55,7 +55,7 @@
 
     sup = parse(os.path.join(srcdir, 'supplemental', 'supplementalData.xml'))
 
-    # import global data from the supplemental files
+    # Import global data from the supplemental files
     global_data = {}
 
     territory_zones = global_data.setdefault('territory_zones', {})
@@ -69,6 +69,14 @@
             for alias in elem.attrib['aliases'].split():
                 zone_aliases[alias] = tzid
 
+    # Import Metazone mapping
+    meta_zones = global_data.setdefault('meta_zones', {})
+    tzsup = parse(os.path.join(srcdir, 'supplemental', 'metazoneInfo.xml'))
+    for elem in tzsup.findall('//timezone'):
+        for child in elem.findall('usesMetazone'):
+            if 'to' not in child.attrib: # FIXME: support old mappings
+                meta_zones[elem.attrib['type']] = child.attrib['mzone']
+
     outfile = open(os.path.join(destdir, 'global.dat'), 'wb')
     try:
         pickle.dump(global_data, outfile, 2)
@@ -197,9 +205,6 @@
                 info.setdefault('long', {})[child.tag] = unicode(child.text)
             for child in elem.findall('short/*'):
                 info.setdefault('short', {})[child.tag] = unicode(child.text)
-            for child in elem.findall('usesMetazone'):
-                if 'to' not in child.attrib: # FIXME: support old mappings
-                    info['use_metazone'] = child.attrib['mzone']
             time_zones[elem.attrib['type']] = info
 
         meta_zones = data.setdefault('meta_zones', {})
Copyright (C) 2012-2017 Edgewall Software