]> projects.mako.cc - iron-blogger/blob - show-week.py
Add cbayley
[iron-blogger] / show-week.py
1 import yaml
2 from dateutil.parser import parse
3 import datetime
4 import dateutil.tz as tz
5 import sys
6 from mako.template import Template
7
8 START = datetime.datetime(2009, 12, 21, 6)
9
10 with open('out/report.yml') as r:
11     report = yaml.safe_load(r)
12
13 with open('bloggers.yml') as f:
14     users = yaml.safe_load(f)
15
16 week = (parse(sys.argv[1], default=START) - START).days / 7
17 week_start = START + (week * datetime.timedelta(7))
18 week_end   = START + ((week + 1) * datetime.timedelta(7))
19
20 good = []
21 lame = []
22 skip = []
23
24
25 for (name, weeks) in report.items():
26     user_start = parse(users[name]['start'], default=START)
27     if user_start > week_start:
28         skip.append(name)
29         continue
30     elif len(weeks) <= week or not weeks[week]:
31         lame.append(name)
32     else:
33         good.append(name)
34
35 print Template(filename=sys.argv[2], output_encoding='utf-8').render(
36     week=week, week_start=week_start,week_end=week_end,
37     good=good, lame=lame, skip=skip, users=users, report=report)

Benjamin Mako Hill || Want to submit a patch?