Browse Source

going from event- to event_ because pelican doesnt like -

master
rra 7 years ago
parent
commit
04bdafae05
  1. 28
      events-ics/events.py

28
events-ics/events.py

@ -58,7 +58,7 @@ def parse_timedelta(ev):
:returns: timedelta :returns: timedelta
""" """
chunks = ev['event-duration'].split() chunks = ev['event_duration'].split()
tdargs = {} tdargs = {}
for c in chunks: for c in chunks:
try: try:
@ -67,11 +67,11 @@ def parse_timedelta(ev):
tdargs[m] = val tdargs[m] = val
except KeyError: except KeyError:
log.error("""Unknown time multiplier '%s' value in the \ log.error("""Unknown time multiplier '%s' value in the \
'event-duration' field in the '%s' event. Supported multipliers \ 'event_duration' field in the '%s' event. Supported multipliers \
are: '%s'.""" % (c, ev['title'], ' '.join(TIME_MULTIPLIERS))) are: '%s'.""" % (c, ev['title'], ' '.join(TIME_MULTIPLIERS)))
raise RuntimeError("Unknown time multiplier '%s'" % c) raise RuntimeError("Unknown time multiplier '%s'" % c)
except ValueError: except ValueError:
log.error("""Unable to parse '%s' value in the 'event-duration' \ log.error("""Unable to parse '%s' value in the 'event_duration' \
field in the '%s' event.""" % (c, ev['title'])) field in the '%s' event.""" % (c, ev['title']))
raise ValueError("Unable to parse '%s'" % c) raise ValueError("Unable to parse '%s'" % c)
@ -96,23 +96,23 @@ def parse_article(generator, metadata):
:returns: None :returns: None
""" """
if 'event-start' not in metadata: if 'event_start' not in metadata:
return return
dtstart = parse_tstamp(metadata, 'event-start') dtstart = parse_tstamp(metadata, 'event_start')
rrule=[] rrule=[]
if 'event-end' in metadata: if 'event_end' in metadata:
dtend = parse_tstamp(metadata, 'event-end') dtend = parse_tstamp(metadata, 'event_end')
elif 'event-duration' in metadata: elif 'event_duration' in metadata:
dtdelta = parse_timedelta(metadata) dtdelta = parse_timedelta(metadata)
dtend = dtstart + dtdelta dtend = dtstart + dtdelta
if 'event-recurring' in metadata: if 'event_recurring' in metadata:
rrule = parse_recursion(metadata, 'event-recurring') rrule = parse_recursion(metadata, 'event_recurring')
else: else:
msg = "Either 'event-end' or 'event-duration' must be" + \ msg = "Either 'event_end' or 'event_duration' must be" + \
" speciefied in the event named '%s'" % metadata['title'] " speciefied in the event named '%s'" % metadata['title']
log.error(msg) log.error(msg)
raise ValueError(msg) raise ValueError(msg)
@ -170,13 +170,13 @@ def generate_ical_file(generator):
priority=5, priority=5,
uid=e.metadata['title'], uid=e.metadata['title'],
) )
if 'event-location' in e.metadata: if 'event_location' in e.metadata:
ie.add('location', e.metadata['event-location']) ie.add('location', e.metadata['event_location'])
elif default_loc: elif default_loc:
ie.add('location', default_loc) ie.add('location', default_loc)
if 'event-recurring' in e.metadata: if 'event_recurring' in e.metadata:
if len(e.rrule)>=2: if len(e.rrule)>=2:
ie.add('rrule', {'freq':e.rrule[0],'until':e.rrule[1]}) ie.add('rrule', {'freq':e.rrule[0],'until':e.rrule[1]})
else: else:

Loading…
Cancel
Save