ical aggregator:

* ignore source lines starting with "#"
 * add alternative parser for event dates given as strings
This commit is contained in:
lars 2009-10-10 23:22:56 +00:00
parent 66fab78c30
commit 76fc4d77cf
2 changed files with 9 additions and 1 deletions

View file

@ -9,6 +9,7 @@ import random
import hmac
import hashlib
import datetime
import dateutil.parser
AUTH_FILE = "stadtgestalten_auth.conf"
@ -43,12 +44,17 @@ def send_xmlrpc_request(server, session, api_key, api_domain, method, args=[]):
def generate_node(title, body, username, time_start, time_finish=None, time_duration_minutes=None):
# parse "time_start", if necessary
if isinstance(time_start, basestring):
time_start = dateutil.parser.parse(time_start)
# calculate "time_finish" if it is not defined
if time_finish is None:
if time_duration_minutes is None:
time_finish = time_start + datetime.timedelta(hours=2)
else:
time_finish = time_start + time_duration_minutes
elif isinstance(time_finish, basestring):
time_finish = dateutil.parser.parse(time_finish)
return {'type': 'termin',
'title': title,
'body': body,

View file

@ -105,6 +105,8 @@ if __name__ == "__main__":
icals = []
for ical_url in ical_urls:
# ignore lines starting with "#"
if not ical_url.startswith("#"):
icals.extend(fetch_ical(ical_url))
for event in icals: