From 81e81fc0096b9eb93ed3dd1f65df5308d0fef610 Mon Sep 17 00:00:00 2001 From: Nelson Elhage Date: Wed, 9 Jun 2010 20:47:02 -0400 Subject: [PATCH] Add summer breaks. --- bloggers.yml | 6 +++++- render.py | 26 +++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/bloggers.yml b/bloggers.yml index 3a3be93..1a397be 100644 --- a/bloggers.yml +++ b/bloggers.yml @@ -7,6 +7,7 @@ adehnert: links: - [Alex Dehnert's Blog, 'http://www.dehnerts.com/~alex/meta/news/', 'http://www.dehnerts.com/~alex/meta/news/?format=rss-full'] start: 12/21 + skip: [[5/31/2010, 8/16/2010]] afarrell: end: 02/01/2010 links: @@ -41,11 +42,13 @@ cslink: links: - [cslink, 'http://cslink.scripts.mit.edu/blog/', 'http://cslink.scripts.mit.edu/blog/?feed=rss2'] start: 12/28 + skip: [[5/31/2010, 9/6/2010]] davidben: links: - [Apparently this installer wants a title, 'http://davidben.scripts.mit.edu/blog/', 'http://davidben.scripts.mit.edu/blog/feed/'] start: 02/15/2010 + skip: [[5/31/2010, 8/30/2010]] ezyang: links: - [Inside 245s, 'http://ezyang.scripts.mit.edu/blog/', 'http://ezyang.scripts.mit.edu/blog/feed/atom/'] @@ -102,7 +105,7 @@ kaduk: kasittig: links: - [Wuthering Snow Mooncrash, 'http://kasittig.scripts.mit.edu/blog/', 'http://kasittig.scripts.mit.edu/blog/?feed=rss2'] - skip: [3/15/2010] + skip: [3/15/2010, [5/31/2010, 8/23/2010]] start: 12/21 kcr: links: @@ -186,6 +189,7 @@ wings: - [PiPER, 'http://wings.scripts.mit.edu/blog/', 'http://wings.scripts.mit.edu/blog/feed/'] - [panscience, 'http://wings.mit.edu/blog/', 'http://wings.mit.edu/blog/feed/'] start: 12/21 + skip: [[5/31/2010, 9/6/2010]] xavid: links: - [Fireflies Sing, 'http://fireflies.xavid.us/', 'http://fireflies.xavid.us/feed/atom/'] diff --git a/render.py b/render.py index cacd90d..0e320bf 100755 --- a/render.py +++ b/render.py @@ -33,6 +33,27 @@ def get_debts(): debts.append((user, val)) return debts +def to_week_num(date): + return (parse(date, default=START) - START).days / 7 + +def parse_skip(rec): + spec = rec.get('skip', []) + out = [] + for s in spec: + if isinstance(s, list): + out.append(map(to_week_num, s)) + else: + out.append(to_week_num(s)) + return out + +def should_skip(skips, week): + for e in skips: + if e == week: + return True + if isinstance(e, list) and e[0] <= week and e[1] > week: + return True + return False + def render_template(path, week=None, **kwargs): with open('out/report.yml') as r: report = yaml.safe_load(r) @@ -62,8 +83,7 @@ def render_template(path, week=None, **kwargs): u.links = rec['links'] u.start = rec['start'] u.end = rec.get('end') - u.skip = [(parse(x, default=START) - START).days / 7 - for x in rec.get('skip', [])] + u.skip = parse_skip(rec) u.weeks = report.get(un, []) userlist.append(u) @@ -78,7 +98,7 @@ def render_template(path, week=None, **kwargs): if u.end and parse(u.end, default=START) <= week_start: continue - if week in u.skip: + if should_skip(u.skip, week): pass elif user_start > week_start: skip.append(u) -- 2.39.5