2009-09-29 15:36:25 -06:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import cgitb; cgitb.enable()
|
2009-10-01 12:17:03 -06:00
|
|
|
import os
|
2009-09-29 15:36:25 -06:00
|
|
|
import config
|
2009-10-01 12:17:03 -06:00
|
|
|
import teams
|
2009-09-29 15:36:25 -06:00
|
|
|
import points
|
|
|
|
|
2009-10-01 12:17:03 -06:00
|
|
|
flags_dir = config.get('global', 'flags_dir')
|
|
|
|
house_team = config.get('global', 'house_team')
|
|
|
|
|
2009-09-29 15:36:25 -06:00
|
|
|
def main():
|
|
|
|
s = points.Storage()
|
|
|
|
|
|
|
|
categories = [(cat, s.cat_points(cat)) for cat in s.categories()]
|
|
|
|
|
|
|
|
print('Content-type: text/html')
|
|
|
|
print()
|
|
|
|
print('''<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
|
|
<head>
|
2009-10-01 12:17:03 -06:00
|
|
|
<title>Scoreboard</title>
|
2009-09-29 15:36:25 -06:00
|
|
|
<link rel="stylesheet" href="%sctf.css" type="text/css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>Scoreboard</h1>
|
|
|
|
''' % config.base_url)
|
2009-10-01 12:17:03 -06:00
|
|
|
print('<table class="scoreboard">')
|
2009-09-29 15:36:25 -06:00
|
|
|
print('<tr>')
|
2009-10-01 12:17:03 -06:00
|
|
|
print('<th>Overall</th>')
|
2009-09-29 15:36:25 -06:00
|
|
|
for cat, score in categories:
|
2009-10-01 12:17:03 -06:00
|
|
|
print('<th>')
|
|
|
|
print(' %s (%d)' % (cat, score))
|
|
|
|
try:
|
|
|
|
fn = os.path.join(flags_dir, cat)
|
|
|
|
team = open(fn).read() or house_team
|
|
|
|
print(' <br/>')
|
|
|
|
print(' <!-- flag: %s --> flag: <span style="color: #%s">%s</span>'
|
|
|
|
% (cat, teams.color(team), team))
|
|
|
|
except IOError:
|
|
|
|
pass
|
|
|
|
print('</th>')
|
2009-09-29 15:36:25 -06:00
|
|
|
print('</tr>')
|
|
|
|
|
|
|
|
print('<tr>')
|
2009-10-01 12:17:03 -06:00
|
|
|
print('<td><ol>')
|
|
|
|
totals = []
|
|
|
|
for team in s.teams:
|
|
|
|
total = s.team_points(team)
|
|
|
|
totals.append((total, team))
|
|
|
|
for total, team in sorted(totals, reverse=True):
|
|
|
|
print('<li><span style="color: #%s;">%s (%0.3f)</span></li>'
|
|
|
|
% (teams.color(team), team, total))
|
|
|
|
print('</ol></td>')
|
2009-09-29 15:36:25 -06:00
|
|
|
for cat, total in categories:
|
2009-10-01 12:17:03 -06:00
|
|
|
print('<td>')
|
|
|
|
scores = sorted([(s.team_points_in_cat(cat, team), team) for team in s.teams])
|
2009-09-29 15:36:25 -06:00
|
|
|
for score, team in scores:
|
2009-10-01 12:17:03 -06:00
|
|
|
color = teams.color(team)
|
2009-09-29 15:36:25 -06:00
|
|
|
print('<div style="height: %f%%; overflow: hidden; background: #%s; color: black;">' % (float(score * 100)/total, color))
|
|
|
|
print('<!-- category: %s --> %s: %d' % (cat, team, score))
|
|
|
|
print('</div>')
|
|
|
|
print('</td>')
|
|
|
|
print('</tr>')
|
|
|
|
print('''</table>
|
|
|
|
|
|
|
|
<img src="histogram.png" alt=""/>
|
|
|
|
</body>
|
|
|
|
</html>''')
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
|
|
|
|
|
|
|
# Local Variables:
|
|
|
|
# mode: python
|
|
|
|
# End:
|