ical aggregator:
* ignore source lines starting with "#" * add alternative parser for event dates given as strings
This commit is contained in:
parent
66fab78c30
commit
76fc4d77cf
2 changed files with 9 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -105,7 +105,9 @@ if __name__ == "__main__":
|
|||
|
||||
icals = []
|
||||
for ical_url in ical_urls:
|
||||
icals.extend(fetch_ical(ical_url))
|
||||
# ignore lines starting with "#"
|
||||
if not ical_url.startswith("#"):
|
||||
icals.extend(fetch_ical(ical_url))
|
||||
|
||||
for event in icals:
|
||||
if not get_unique_id(event) in finished_items:
|
||||
|
|
Loading…
Reference in a new issue