From 1a7f8e3e07ffd99b36cbb0504b0359c089e9f3a4 Mon Sep 17 00:00:00 2001 From: James French Date: Wed, 15 Jun 2011 00:07:27 +0800 Subject: [PATCH] Parser rules update. - Extended Content Rules made a little less zealous - Facebook organiser included in the description (Google Calendar hides it) - Multiple EXDATE entries broken out from single lines to multiple. --- parserrules.py | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/parserrules.py b/parserrules.py index 0ac3d97..424de51 100644 --- a/parserrules.py +++ b/parserrules.py @@ -36,11 +36,14 @@ def facebookOrganiser(cal): for event in cal.vevent_list: if not event.contents.has_key(u'organizer'): continue - organizer = "Organised by: " + event.organizer.cn_param + " (" - organizer += event.organizer.value.lstrip('MAILTO:') + ")\n\n" - - event.description.value = organizer + event.description.value - + try: + a = event.organizer.cn_paramlist + organizer = "Organised by: " + event.organizer.cn_param + " (" + organizer += event.organizer.value.lstrip('MAILTO:') + ")\n\n" + event.description.value = organizer + event.description.value + except AttributeError: + organizer = "Organized by: " + event.organizer.value + event.description.value = organizer + "\n\n" + event.description.value return cal def whatPrivacy(cal): @@ -68,27 +71,26 @@ def dropMSKeys(cal): "X-MS-OLK-AUTOFILLLOCATION" ]] - vcalBlacklist = [x.lower() for x in [ - "X-CALEND", - "X-CALSTART", - "X-CLIPEND", - "X-CLIPSTART", - "X-MS-OLK-WKHRDAYS", - "X-MS-OLK-WKHREND", - "X-MS-OLK-WKHRSTART", - "X-OWNER", - "X-PRIMARY-CALENDAR", - "X-PUBLISHED-TTL", - "X-WR-CALDESC", - "X-WR-CALNAME", - "X-WR-RELCALID" - ]] - for event in cal.vevent_list: for blacklist in eventBlacklist: if event.contents.has_key(blacklist): del event.contents[blacklist] - for blacklist in vcalBlacklist: - if cal.contents.has_key(blacklist): del cal.contents[blacklist] + return cal + +def exDate(cal): + '''Changes multi-EXDATE into singles (apple can't obey even simple specs)''' + + for event in cal.vevent_list: + if not event.contents.has_key(u'exdate'): continue + dates = event.exdate.value + try: tzid = event.exdate.tzid_param + except AttributeError: tzid = '' + + del event.contents[u'exdate'] + + for date in dates: + entry = event.add(u'exdate') + entry.value = [date] + if tzid: entry.tzid_param = tzid return cal -- 2.20.1