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')
12 url =
'https://raw.githubusercontent.com/unicode-org/cldr/main/common/supplemental/windowsZones.xml'
15 with urllib.request.urlopen(url)
as response:
17 root = ET.fromstring(xml)
19 for child
in root.iter(
'mapZone'):
20 tzid = child.get(
'type')
21 windows = child.get(
'other')
22 entries += [
'\t{ "' + windows +
'", "' + tzid +
'" },\n']
25 with open(zfile,
'w')
as f:
27 f.write(
' * Automatically generated with ' + str(rname) +
'\n')
30 f.write(
'#include "WindowsZones.h"\n')
32 f.write(
'const WINDOWS_TZID_ENTRY WindowsTimeZoneIdTable[] =\n')
38 f.write(
'const size_t WindowsTimeZoneIdTableNrElements = ARRAYSIZE(WindowsTimeZoneIdTable);\n')
39 except Exception
as e:
40 print(
'----------------------------------------------------')
42 print(
'----------------------------------------------------')