forked from d101tm/tmstats
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakealignmentpage.py
More file actions
executable file
·83 lines (66 loc) · 2.59 KB
/
makealignmentpage.py
File metadata and controls
executable file
·83 lines (66 loc) · 2.59 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python3
""" Create the index.html page for the alignment directory on d101tm """
import os
import sys
from time import localtime, strftime
import tmglobals
myglobals = tmglobals.tmglobals()
### Insert classes and functions here. The main program begins in the "if" statement below.
if __name__ == "__main__":
import tmparms
# Handle parameters
parms = tmparms.tmparms()
parms.add_argument('--quiet', '-q', action='count')
parms.add_argument('--fordec', action='store_true')
parms.add_argument('--outdir', type=str, default='${alignmentdir}')
# Do global setup
myglobals.setup(parms, sections='alignment')
conn = myglobals.conn
curs = myglobals.curs
os.chdir(parms.outdir)
class alignmentfile:
def __init__(self, filename):
self.filename = filename
self.mtime = localtime(os.path.getmtime(filename))
def makeitem(self, s):
return f'<li><a href="{self.filename}">{s}</a></li>'
filenames = ['detailfile', 'markerfile', 'mapfile', 'reportfile', 'summaryfile', 'colordetailfile',
'changesfile', 'postdecchangesfile']
files = {n:alignmentfile(getattr(parms, n, None)) for n in filenames}
lastupdate = strftime('%B %-d, %Y at %-I:%M %p', max([files[item].mtime for item in files]))
details = []
details.append(files['summaryfile'].makeitem('summary'))
details.append(files['mapfile'].makeitem('map'))
if not parms.fordec:
details.append(files['detailfile'].makeitem('detailed list with club meeting times and places'))
else:
details.append(files['colordetailfile'].makeitem('detailed list with club meeting times and places'))
details.append(files['reportfile'].makeitem('<i>pro forma</i> performance report'))
sys.stdout.write(f"""<html>
<head>
<title>D101 Proposed Realignment as of {lastupdate}</title>
</head>
<body>
<p>This page lets you see the proposed realignment as of {lastupdate}:
<ul>
%s
</ul>
""" % ('\n'.join(details)))
sys.stdout.write(open(parms.datacurrencyfile).read())
if parms.fordec:
sys.stdout.write("""
<p>In addition, there is information on club changes:
<ul>
%s
""" % files['changesfile'].makeitem('Club changes since July 1'))
if (open(files['postdecchangesfile'].filename, 'r').readlines()):
sys.stdout.write("""
%s
""" % files['postdecchangesfile'].makeitem('Club changes since the DEC meeting'))
sys.stdout.write("""
</ul>
""")
sys.stdout.write("""
</body>
</html>
""")