6 from dateutil.parser import parse
7 import dateutil.tz as tz
9 with open('bloggers.yml') as f:
10 users = yaml.safe_load(f.read())
14 START = datetime.datetime(2009, 12, 21, 6)
16 def parse_published(pub):
17 return parse(pub).astimezone(tz.tzlocal()).replace(tzinfo=None)
20 if 'published' in post:
27 def parse_feeds(weeks, uri):
28 feed = feedparser.parse(uri)
30 print >>sys.stderr, "WARN: no entries for ", uri
31 for post in feed.entries:
32 date = parse_published(get_date(post))
36 wn = (date - START).days / 7
38 while len(weeks) <= wn:
40 weeks[wn].append(dict(
45 for (username, u) in users.items():
47 print "[%s]" % (username)
49 parse_feeds(weeks, l[2])
51 for (i, w) in enumerate(weeks):
52 print " [%d]: %s" % (i, w)
54 with open('out/report.yml', 'w') as f:
55 yaml.safe_dump(log, f)