[Debconf-video-commits] r333 - package/branches/pycon09/src
benh at alioth.debian.org
benh at alioth.debian.org
Thu Mar 19 00:00:42 UTC 2009
Author: benh
Date: 2009-03-19 00:00:41 +0000 (Thu, 19 Mar 2009)
New Revision: 333
Modified:
package/branches/pycon09/src/dc-video-schema.sql
package/branches/pycon09/src/pycon-import-talks
Log:
Since we can't guarantee to get unique event ids from the multiple event sources, add a source_url to and invent our own ids.
Modified: package/branches/pycon09/src/dc-video-schema.sql
===================================================================
--- package/branches/pycon09/src/dc-video-schema.sql 2009-03-18 23:56:09 UTC (rev 332)
+++ package/branches/pycon09/src/dc-video-schema.sql 2009-03-19 00:00:41 UTC (rev 333)
@@ -23,6 +23,7 @@
-- Event details, imported from master database.
CREATE TABLE event (
event_id serial PRIMARY KEY,
+ source_url character varying(200) NOT NULL UNIQUE,
conference_id integer NOT NULL,
conference_room character varying(100) NOT NULL,
title character varying(200) NOT NULL,
Modified: package/branches/pycon09/src/pycon-import-talks
===================================================================
--- package/branches/pycon09/src/pycon-import-talks 2009-03-18 23:56:09 UTC (rev 332)
+++ package/branches/pycon09/src/pycon-import-talks 2009-03-19 00:00:41 UTC (rev 333)
@@ -10,6 +10,8 @@
import urllib2
import vobject
+SOURCE_URL = 'http://us.pycon.org/2009/conference/schedule/ical/'
+
_connection = None
def get_cursor():
@@ -29,7 +31,7 @@
def main(pretend=False):
local_tz = pytz.timezone('America/Chicago')
- for event in get_events('http://us.pycon.org/2009/conference/schedule/ical/'):
+ for event in get_events(SOURCE_URL):
values = {'conference_id': 1}
# Drop id number found in some summaries.
@@ -50,8 +52,7 @@
values['conference_room'] = match.group(1)
values['description'] = match.group(2)
- match = re.match(r'event_E(\d+)@pycon\.org$', event['UID'])
- values['event_id'] = int(match.group(1))
+ values['source_url'] = SOURCE_URL + '#' + event['UID']
values['start_time'] = event['DTSTART'].astimezone(local_tz).isoformat(' ')
values['duration'] = '%d SECONDS' % (event['DTEND'] - event['DTSTART']).seconds
@@ -69,12 +70,15 @@
values)
# Insert/update event
- cur.execute('SELECT COUNT(*) FROM event WHERE event_id=%(event_id)d',
+ cur.execute('SELECT event_id FROM event WHERE source_url=%(source_url)s',
values)
if pretend:
pass
- elif cur.fetchone()[0]:
+ row = cur.fetchone()
+ if row:
+ values['event_id'] = row[0]
cur.execute('UPDATE event SET'
+ ' source_url=%(source_url)s,'
' conference_room=%(conference_room)s,'
' title=%(title)s,'
' description=%(description)s,'
@@ -83,10 +87,10 @@
' WHERE event_id=%(event_id)d',
values)
else:
- cur.execute('INSERT INTO event(event_id, conference_id,'
+ cur.execute('INSERT INTO event(source_url, conference_id,'
' conference_room, title, description,'
' start_time, duration)'
- ' VALUES(%(event_id)d, %(conference_id)d,'
+ ' VALUES(%(source_url)s, %(conference_id)d,'
' %(conference_room)s, %(title)s,'
' %(description)s, '
' %(start_time)s,'
More information about the Debconf-video-commits
mailing list