4 from dateutil.parser import parse
5 import dateutil.tz as tz
7 with open('bloggers.yml') as f:
8 users = yaml.safe_load(f.read())
12 START = datetime.datetime(2009, 12, 21, 6)
14 def parse_published(pub):
15 return parse(pub).astimezone(tz.tzlocal()).replace(tzinfo=None)
18 if 'published' in post:
25 return post.links[0]['href']
27 def parse_feeds(weeks, uri):
28 feed = feedparser.parse(uri)
29 for post in feed.entries:
30 date = parse_published(get_date(post))
34 wn = (date - START).days / 7
36 while len(weeks) <= wn:
38 weeks[wn].append(dict(
43 for (username, u) in users.items():
45 print "[%s]" % (username)
47 parse_feeds(weeks, l[2])
49 for (i, w) in enumerate(weeks):
50 print " [%d]: %s" % (i, w)
52 with open('out/report.yml', 'w') as f:
53 yaml.safe_dump(log, f)