diff options
Diffstat (limited to 'tools/make_iata.py')
-rwxr-xr-x | tools/make_iata.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/make_iata.py b/tools/make_iata.py new file mode 100755 index 0000000..5644469 --- /dev/null +++ b/tools/make_iata.py | |||
@@ -0,0 +1,34 @@ | |||
1 | #!/usr/bin/env python3 | ||
2 | |||
3 | # Copyright (C) 2019 James E. Blair <corvus@gnu.org> | ||
4 | # | ||
5 | # This file is part of Email-assistant. | ||
6 | # | ||
7 | # Email-assistant is free software: you can redistribute it and/or | ||
8 | # modify it under the terms of the GNU Affero General Public License | ||
9 | # as published by the Free Software Foundation, either version 3 of | ||
10 | # the License, or (at your option) any later version. | ||
11 | # | ||
12 | # Email-assistant is distributed in the hope that it will be useful, | ||
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | # General Public License for more details. | ||
16 | # | ||
17 | # You should have received a copy of the GNU General Public License | ||
18 | # along with Email-assistant. If not, see | ||
19 | # <https://www.gnu.org/licenses/>. | ||
20 | |||
21 | # Create the iata.py file from upstream data. | ||
22 | |||
23 | import urllib.request | ||
24 | |||
25 | f = urllib.request.urlopen("https://raw.githubusercontent.com/hroptatyr/dateutils/tzmaps/iata.tzmap") | ||
26 | data = f.read().decode('ascii') | ||
27 | |||
28 | with open('iata.py', 'w') as out: | ||
29 | out.write('tzmap = {\n') | ||
30 | for line in data.split('\n'): | ||
31 | if not line: continue | ||
32 | code, tz = [x.strip() for x in line.split()] | ||
33 | out.write(" '%s': '%s',\n" % (code, tz)) | ||
34 | out.write('}\n') | ||