5 import xml.etree.ElementTree as ET
7 name = os.path.realpath(__file__)
8 base = os.path.normpath(os.path.join(os.path.dirname(name), '..'))
9 rname = os.path.relpath(name, base)
10 zfile = os.path.join(base, 'winpr/libwinpr/timezone/WindowsZones.c')
11 url = 'https://raw.githubusercontent.com/unicode-org/cldr/latest/common/supplemental/windowsZones.xml'
14 with urllib.request.urlopen(url) as response:
16 root = ET.fromstring(xml)
18 for child in root.iter('mapZone'):
19 tzid = child.get('type')
20 windows = child.get('other')
21 entries += ['\t{ "' + windows + '", "' + tzid + '" },\n']
24 with open(zfile, 'w') as f:
26 f.write(' * Automatically generated with ' + str(rname) + '\n')
29 f.write('#include "WindowsZones.h"\n')
31 f.write('const WINDOWS_TZID_ENTRY WindowsTimeZoneIdTable[] =\n')
37 f.write('const size_t WindowsTimeZoneIdTableNrElements = ARRAYSIZE(WindowsTimeZoneIdTable);\n')
38 except Exception as e:
39 print('----------------------------------------------------')
41 print('----------------------------------------------------')