-
-
Notifications
You must be signed in to change notification settings - Fork 93
/
gen_tests.py
46 lines (37 loc) · 1.23 KB
/
gen_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
# -*- coding: ascii -*-
'''
$Id: gen_tests.py,v 1.15 2005/01/07 04:51:30 zenzen Exp $
'''
import os
import os.path
import subprocess
import sys
from gen_tzinfo import allzones
import gen_tzinfo
zdump = os.path.abspath(os.path.join(
os.path.dirname(__file__), 'build', 'bin', 'zdump'
))
def main():
dest_dir = os.path.abspath(os.path.join(os.path.dirname(__file__)))
datf = open(os.path.join(dest_dir, 'zdump.out'), 'w')
for zone in allzones():
print('Collecting zdump(1) output for %s in zdump.out' % (zone,))
# We don't yet support v2 format tzfile(5) files, so limit
# the daterange we test against - zdump understands v2 format
# files and will output historical records we can't cope with
# otherwise.
command = [zdump, '-V', '-c', '1902,2038', zone]
zd_out = subprocess.check_output(command, encoding="utf8")
lines = [line.strip() for line in zd_out.splitlines()]
for line in lines:
print(line, file=datf)
datf.flush()
datf.close()
if __name__ == '__main__':
try:
gen_tzinfo.target = sys.argv[1:]
except IndexError:
gen_tzinfo.target = None
main()
# vim: set filetype=python ts=4 sw=4 et