]> projects.mako.cc - iron-blogger/commitdiff
Add summer breaks.
authorNelson Elhage <nelhage@ksplice.com>
Thu, 10 Jun 2010 00:47:02 +0000 (20:47 -0400)
committerNelson Elhage <nelhage@ksplice.com>
Thu, 10 Jun 2010 00:47:02 +0000 (20:47 -0400)
bloggers.yml
render.py

index 3a3be93c255f2b1d0beede6c0581da9e89b6acb8..1a397be6dcbbde1c2d7c39af82c6636e230997f3 100644 (file)
@@ -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
   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:
 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
   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
 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/']
 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']
 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:
   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
   - [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/']
 xavid:
   links:
   - [Fireflies Sing, 'http://fireflies.xavid.us/', 'http://fireflies.xavid.us/feed/atom/']
index cacd90da6360c8fe2b799eb21f4f81b05d6ce826..0e320bf5afb2d995a49f6429f73bc5a816cd4ed5 100755 (executable)
--- a/render.py
+++ b/render.py
@@ -33,6 +33,27 @@ def get_debts():
         debts.append((user, val))
     return 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)
 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.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)
         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 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)
             pass
         elif user_start > week_start:
             skip.append(u)

Benjamin Mako Hill || Want to submit a patch?