[Debconf-video-commits] r327 - package/branches/pycon09/src

benh at alioth.debian.org benh at alioth.debian.org
Mon Mar 16 04:04:38 UTC 2009


Author: benh
Date: 2009-03-16 04:04:38 +0000 (Mon, 16 Mar 2009)
New Revision: 327

Added:
   package/branches/pycon09/src/pycon-import-talks
Log:
Add script to import talks from public schedule.


Added: package/branches/pycon09/src/pycon-import-talks
===================================================================
--- package/branches/pycon09/src/pycon-import-talks	                        (rev 0)
+++ package/branches/pycon09/src/pycon-import-talks	2009-03-16 04:04:38 UTC (rev 327)
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+
+# Import talks from public schedule in ICS format
+
+import pgdb
+import re
+import sys
+import urllib2
+import vobject
+
+def get_events(url):
+    data = urllib2.urlopen(url).read()
+    for node in vobject.readOne(data).getChildren():
+        if node.name == 'VEVENT':
+            yield dict((attr.name, attr.value) for attr in node.getChildren())
+
+def main(pretend=False):
+    for event in get_events('http://us.pycon.org/2009/conference/schedule/ical/'):
+        # Drop id number found in some summaries.
+        title = re.sub(r' \(#\d+\)$', '', event['SUMMARY'])
+
+        # Drop metadata at top of description, but hold onto the room name.
+        # Drop events which don't have this metadata, as they are such
+        # exciting talks as 'Lunch'.
+        match = re.match(r'Room: (?!None\n)([^\n]*)\n'
+                         r'Presenters: [^\n]*\n'
+                         r'\d+min [^\n]*\n'
+                         r'(?:categories: [^\n]*\n)?'
+                         r'(.*)',
+                         event['DESCRIPTION'])
+        if not match:
+            print 'INFO: Ignoring', title
+            continue
+        room_name, description = match.group(1, 2)
+
+        match = re.match(r'event_E(\d+)@pycon\.org$', event['UID'])
+        event_id = int(match.group(1))
+        start_time = event['DTSTART']
+        duration = event['DTEND'] - start_time
+
+        # TODO: Insert room in conference_room table if not present
+        # TODO: Insert/update event ine vent table
+        print event_id, title, description[:20], room_name, start_time, duration
+
+if __name__ == '__main__':
+    try:
+        sys.path.insert(0, '/usr/share/debconf-video-store')
+        import shellconfig
+        config = shellconfig.read_file('/etc/default/debconf-video')
+        main(pretend=('--dry-run' in sys.argv[1:]))
+    except Exception, e:
+        print >>sys.stderr, 'ERROR:', e.__class__.__name__, e
+        sys.exit(2)




More information about the Debconf-video-commits mailing list