OILS / devtools / release_history.py View on Github | oilshell.org

84 lines, 58 significant
1#!/usr/bin/env python2
2"""
3release_history.py
4"""
5from __future__ import print_function
6
7import os, re, subprocess, sys, zipfile
8
9def log(msg, *args):
10 if args:
11 msg = msg % args
12 print('\t' + msg, file=sys.stderr)
13
14VERSION_RE = re.compile('0\.(\d+)\.(\w+)')
15HEADER=('date', 'version', 'spec_wwz', 'survey_path', 'cpp_summary_path')
16
17def main(argv):
18
19 print('\t'.join(HEADER))
20
21 for release_dir in sys.stdin:
22 release_dir = release_dir.strip()
23
24 #print(release_dir)
25 m = VERSION_RE.search(release_dir)
26 assert m is not None
27
28 version = m.group(0)
29
30 p = os.path.join(release_dir, 'release-date.txt')
31 with open(p) as f:
32 date = f.readline().strip()
33
34 # 0.9.3 is missing
35 #print('%s\t%s' % (date, version))
36 spec_wwz = os.path.join(release_dir, 'test/spec.wwz')
37 if not os.path.exists(spec_wwz):
38 log('No spec.wwz; skipping %s %s', date, version)
39 print('\t'.join([date, version, '-', '-', '-']))
40 continue
41
42 with open(spec_wwz) as f:
43 z = zipfile.ZipFile(f)
44
45 survey_path = '-'
46
47 p1 = 'survey/osh.html'
48 try:
49 z.getinfo(p1)
50 survey_path = p1
51 except KeyError:
52 pass
53
54 if survey_path == '-':
55 p2 = 'osh.html'
56 try:
57 z.getinfo(p2)
58 survey_path = p2
59 except KeyError:
60 pass
61
62 if survey_path == '-':
63 p3 = 'index.html'
64 try:
65 z.getinfo(p3)
66 survey_path = p3
67 except KeyError:
68 pass
69
70 cpp_summary_path = 'cpp/osh-summary.html'
71 try:
72 h2 = z.getinfo(cpp_summary_path)
73 except KeyError:
74 cpp_summary_path = '-'
75
76 print('\t'.join([date, version, spec_wwz, survey_path, cpp_summary_path]))
77
78
79if __name__ == '__main__':
80 try:
81 main(sys.argv)
82 except RuntimeError as e:
83 print('FATAL: %s' % e, file=sys.stderr)
84 sys.exit(1)