New schedule, plus machinery to maintain it
[scons.git] / www / gen_sched_table.py
1 #!/usr/bin/env python
2
3 import sys
4 import datetime
5
6 months = ['January', 'February', 'March', 'April', 'May', 'June', 'July',
7           'August', 'September', 'October', 'November', 'December']
8
9 print '<table>'
10 def row(*cells, **kw):
11         tr = kw.get('tr','tr')
12         print '  <tr>'
13         for cell in cells:
14                 print '    <%s>%s</%s>' % (tr,cell,tr)
15         print '  </tr>'
16 row('Estimated date', 'Type', 'Name', 'Comments', tr = 'th')
17
18 if len(sys.argv) > 1:
19         f = open(sys.argv[1])
20 else:   f = open('Schedule')
21 now = None
22 current = 'UNKNOWN'
23 for line in f:
24         if line[0] == '#': continue     # comment
25         if line[0] == '=':
26                 date,current = line[1:].strip().split()
27                 now = datetime.date(*tuple([int(i) for i in date.split('-')]))
28                 continue
29         if line[0] == '+':
30                 incr,type,desc = line[1:].strip().split(None,2)
31                 now = now + datetime.timedelta(int(incr))
32         else:
33                 print 'dunna understand code', line[0]
34                 sys.exit(1)
35         name = current + '.d' + str(now).replace('-','')
36         date = '%s %s %s' % (now.day,months[now.month-1],now.year)
37         if type == 'ck':
38                 category = 'checkpoint'
39         elif type == 'rc':
40                 category = 'candidate'
41         else:
42                 current = name = type
43                 category = 'release'
44         row(date, category, name, desc)
45 print '</table>'