show-week: use a mako template
Add a template for sending email, as well.
This commit is contained in:
parent
32e6bed76a
commit
364ecc7623
15
show-week.py
15
show-week.py
|
@ -3,6 +3,7 @@ from dateutil.parser import parse
|
|||
import datetime
|
||||
import dateutil.tz as tz
|
||||
import sys
|
||||
from mako.template import Template
|
||||
|
||||
START = datetime.datetime(2009, 12, 21, 6)
|
||||
|
||||
|
@ -16,13 +17,21 @@ week = (parse(sys.argv[1], default=START) - START).days / 7
|
|||
week_start = START + (week * datetime.timedelta(7))
|
||||
week_end = START + ((week + 1) * datetime.timedelta(7))
|
||||
|
||||
good = []
|
||||
lame = []
|
||||
skip = []
|
||||
|
||||
|
||||
for (name, weeks) in report.items():
|
||||
user_start = parse(users[name]['start'], default=START)
|
||||
if user_start > week_start:
|
||||
print "SKIP %s" % (name,)
|
||||
skip.append(name)
|
||||
continue
|
||||
elif len(weeks) <= week or not weeks[week]:
|
||||
print "LAME %s" % (name,)
|
||||
lame.append(name)
|
||||
else:
|
||||
print "OK %s" % (name,)
|
||||
good.append(name)
|
||||
|
||||
print Template(filename=sys.argv[2], output_encoding='utf-8').render(
|
||||
week=week, week_start=week_start,week_end=week_end,
|
||||
good=good, lame=lame, skip=skip, users=users, report=report)
|
||||
|
|
26
templates/email.txt
Normal file
26
templates/email.txt
Normal file
|
@ -0,0 +1,26 @@
|
|||
Subject: IRON BLOGGER results for the week of ${week_start.strftime("%F")}
|
||||
To: iron-blogger@mit.edu
|
||||
|
||||
People who posted:
|
||||
% for u in sorted(good):
|
||||
<% posts = report[u][week] %>\
|
||||
${u}:
|
||||
% for p in posts:
|
||||
- ${p['url']}
|
||||
% endfor
|
||||
% endfor
|
||||
|
||||
People who failed to post:
|
||||
<% cash = 0 %>\
|
||||
% for u in sorted(lame):
|
||||
${u}
|
||||
% endfor
|
||||
|
||||
People who have not yet started:
|
||||
% for u in sorted(skip):
|
||||
${u}
|
||||
% endfor
|
||||
|
||||
Beer pool:
|
||||
This week: $${5 * len(lame)}.00
|
||||
Total: $.00
|
Loading…
Reference in a new issue