2 from dateutil.parser import parse
4 import dateutil.tz as tz
6 from mako.template import Template
8 START = datetime.datetime(2009, 12, 21, 6)
10 with open('out/report.yml') as r:
11 report = yaml.safe_load(r)
13 with open('bloggers.yml') as f:
14 users = yaml.safe_load(f)
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))
25 for (name, weeks) in report.items():
26 user_start = parse(users[name]['start'], default=START)
27 if user_start > week_start:
30 elif len(weeks) <= week or not weeks[week]:
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)