[Python-checkins] r42213 - sandbox/trunk/pycon/parse_sched.py
andrew.kuchling
python-checkins at python.org
Wed Feb 1 01:03:24 CET 2006
Author: andrew.kuchling
Date: Wed Feb 1 01:03:22 2006
New Revision: 42213
Modified:
sandbox/trunk/pycon/parse_sched.py
Log:
Patch from Duncan McGreggor: add iCal output to parse_sched
Modified: sandbox/trunk/pycon/parse_sched.py
==============================================================================
--- sandbox/trunk/pycon/parse_sched.py (original)
+++ sandbox/trunk/pycon/parse_sched.py Wed Feb 1 01:03:22 2006
@@ -199,11 +199,44 @@
format_day(day_data, output)
+def event (day, talk, output):
+ location, texttime, duration, title = talk
+ idx = title.replace('#', '')
+ try:
+ title = "%s (%s)" % (talks.talk_dict.get(int(idx)), title)
+ except ValueError:
+ pass
+ talk_title = talks.talk_dict.get(title.replace('#', '')) or title
+ date = list(day) + [ int(x) for x in texttime.split(':') ]
+ date = datetime.datetime(*date).strftime("%Y%m%dT%H%M00")
+ print >>output, 'BEGIN:VEVENT\n'
+ print >>output, 'DTSTART;TZID=US-Eastern:%s\n' % date
+ print >>output, 'LOCATION:Dallas, TX\n'
+ print >>output, 'SUMMARY: %s\n' % talk_title
+ print >>output, 'UID:%s@%s\n' % (date, 'pycon.org')
+ print >>output, 'SEQUENCE:1\n'
+ # XXX what are these two?
+ print >>output, 'DTSTAMP: %s\n' % date
+ print >>output, 'DURATION:PT%iM\n' % duration
+ print >>output, 'END:VEVENT\n\n'
+
+def output_ical (d, output):
+ print >>output, 'BEGIN:VCALENDAR\n'
+ print >>output, 'VERSION:2.0\n'
+ print >>output, 'PRODID:-//Conference Software//EN\n'
+ print >>output, 'CALSCALE:GREGORIAN\n'
+ print >>output, 'X-WR-CALNAME: PyCon 2006 Talks\n'
+ print >>output, '\n'
+ for day in d:
+ for talk in d[day]:
+ event(day, talk, output)
+ print >>output, 'END:VCALENDAR\r\n'
+
def main ():
parser = optparse.OptionParser(usage="usage: %prog [options] < final-schedule")
parser.add_option('--format',
type='choice',
- choices=['pickle', 'python', 'print', 'html'],
+ choices=['pickle', 'python', 'print', 'html', 'ical'],
default='print',
action="store", dest="format",
help = "Select output format")
@@ -221,6 +254,8 @@
cPickle.dump(d, sys.stdout)
elif fmt == 'html':
output_html(d, sys.stdout)
+ elif fmt == 'ical':
+ output_ical(d, sys.stdout)
else:
print >>sys.stderr, "Unknown format %r" % fmt
sys.exit(1)
More information about the Python-checkins
mailing list