summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Bishop <stuart.bishop@canonical.com>2021-03-22 08:36:34 +0000
committerStuart Bishop <stuart.bishop@canonical.com>2021-03-22 08:36:34 +0000
commitdf59d3af429d46ee575ab5d3a7fe3f8cd49a74bc (patch)
tree76f692b5a6404db3f060690fdb1d8fc5339ba3d7
parentaed1838c4010780a5826c917794a53a0408dff39 (diff)
downloadpytz-git-df59d3af429d46ee575ab5d3a7fe3f8cd49a74bc.tar.gz
Complete switch of code generation to Python3
-rw-r--r--Makefile3
-rw-r--r--gen_tests.py6
-rw-r--r--gen_tzinfo.py11
3 files changed, 9 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index ac0a755..5c42fb3 100644
--- a/Makefile
+++ b/Makefile
@@ -16,8 +16,9 @@ PYTHON36=python3.6
PYTHON37=python3.7
PYTHON38=python3.8
PYTHON39=python3.9
-PYTHON=/usr/bin/python
+PYTHON2=/usr/bin/python2
PYTHON3=/usr/bin/python3
+PYTHON=${PYTHON3}
IANA=./tz
IANA_GIT=https://github.com/eggert/tz.git
diff --git a/gen_tests.py b/gen_tests.py
index cff1204..5ba0648 100644
--- a/gen_tests.py
+++ b/gen_tests.py
@@ -28,14 +28,14 @@ def main():
# 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)
+ zd_out = subprocess.check_output(command, encoding="utf8")
# Skip bogus output on 64bit architectures, per Bug #213816
lines = [
line.strip() for line in zd_out.splitlines()
- if not line.decode('utf-8').strip().endswith('NULL')]
+ if not line.strip().endswith('NULL')]
for line in lines:
- print >> datf, line
+ print(line, file=datf)
datf.flush()
datf.close()
diff --git a/gen_tzinfo.py b/gen_tzinfo.py
index 0d1c9c8..3c372dd 100644
--- a/gen_tzinfo.py
+++ b/gen_tzinfo.py
@@ -23,7 +23,7 @@ def allzones():
for dirpath, dirnames, filenames in os.walk(zoneinfo):
for f in filenames:
p = os.path.join(dirpath, f)
- if open(p, 'rb').read(4) == 'TZif':
+ if open(p, 'rb').read(4) == b'TZif':
zones.append(p)
stripnum = len(os.path.commonprefix(zones))
zones = [z[stripnum:] for z in zones]
@@ -41,19 +41,16 @@ def allzones():
zones = [z for z in zones if 'Riyadh8' not in z and z not in [
'Factory', 'localtime', 'posixrules']]
zones.sort()
+ assert len(zones) > 0
return zones
def links():
'''Mapping of alias -> canonical name'''
l = {}
- olson_src_files = glob('tz/*')
- assert olson_src_files, 'No src files'
+ olson_src_files = ['tz/vanguard.zi', 'tz/main.zi', 'tz/rearguard.zi']
for filename in olson_src_files:
- # Filenames containing a '.' are not data files.
- if '.' in os.path.basename(filename):
- continue
- for line in open(filename):
+ for line in open(filename, 'r'):
if line.strip().startswith('#') or not line.strip():
continue
match = re.search(r'^\s*Link\s+([\w/\-]+)\s+([\w/\-]+)', line)