import datetime
import dateutil.tz as tz
import sys
+from mako.template import Template
START = datetime.datetime(2009, 12, 21, 6)
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)
--- /dev/null
+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