Removed functions to do with Outlook ICS Files
[frenchie/icalparse.git] / parserrules.py
index 791a860..a2175fe 100644 (file)
@@ -28,6 +28,9 @@
 
 import vobject
 
+ruleConfig = {}
+ruleConfig["defaultTZ"] = "UTC"
+
 def facebookOrganiser(cal):
        '''Adds organiser details to the body of facebook calendars.'''
 
@@ -51,48 +54,9 @@ def whatPrivacy(cal):
 
        for event in cal.vevent_list:
                if event.contents.has_key(u'class'):
-                       getattr(event, 'class').value = "PUBLIC"
-
-       return cal
-
-def dropAttributes(cal):
-       '''Removing unwanted metadata'''
-
-       eventBlacklist = [x.lower() for x in [
-               "X-ALT-DESC",
-               "X-MICROSOFT-CDO-BUSYSTATUS",
-               "X-MICROSOFT-CDO-IMPORTANCE",
-               "X-MICROSOFT-DISALLOW-COUNTER",
-               "X-MS-OLK-ALLOWEXTERNCHECK",
-               "X-MS-OLK-AUTOSTARTCHECK",
-               "X-MS-OLK-CONFTYPE",
-               "X-MS-OLK-AUTOFILLLOCATION",
-               "TRANSP",
-               "SEQUENCE",
-               "PRIORITY"
-       ]]
-
-       mainBlacklist = [x.lower() for x in [
-               "X-CLIPSTART",
-               "X-CALSTART",
-               "X-OWNER",
-               "X-MS-OLK-WKHRSTART",
-               "X-MS-OLK-WKHREND",
-               "X-WR-RELCALID",
-               "X-MS-OLK-WKHRDAYS",
-               "X-MS-OLK-APPTSEQTIME",
-               "X-CLIPEND",
-               "X-CALEND",
-               "VTIMEZONE",
-               "X-PRIMARY-CALENDAR"
-       ]]
-
-       for event in cal.vevent_list:
-               for blacklist in eventBlacklist:
-                       if event.contents.has_key(blacklist): del event.contents[blacklist]
-
-       for blkl in mainBlacklist:
-               while blkl in cal.contents: del cal.contents[blkl]
+                       # Bit of a hack as class is a reserved word in python
+                       del event.contents[u'class']
+                       event.add('class').value = "PUBLIC"
 
        return cal
 
@@ -102,8 +66,7 @@ def exDate(cal):
        from datetime import datetime
        from pytz import timezone
 
-       default = timezone('Australia/Perth')
-
+       default = timezone(ruleConfig["defaultTZ"])
 
        for event in cal.vevent_list:
                if not event.contents.has_key(u'exdate'): continue
@@ -112,23 +75,22 @@ def exDate(cal):
                del event.contents[u'exdate']
 
                for date in dates:
-                       print date
                        if isinstance(date, datetime):
                                if date.tzinfo is None: date = date.replace(tzinfo = default)
                                date = date.astimezone(vobject.icalendar.utc)
-                       print date
                        entry = event.add(u'exdate')
                        entry.value = [date]
 
        return cal
 
 def utcise(cal):
-       '''Removing local timezones in favour of UTC'''
+       '''Removing local timezones in favour of UTC. If the remote calendar specifies a timezone
+       then use it, otherwise assume it's in the user-specified or default values'''
 
        from datetime import datetime
        from pytz import timezone
 
-       default = timezone('Australia/Perth')
+       default = timezone(ruleConfig["defaultTZ"])
 
        for event in cal.vevent_list:
                dtstart = getattr(event, 'dtstart', None)
@@ -161,4 +123,3 @@ def unwantedParams(cal):
                        except AttributeError: continue
 
        return cal
-

UCC git Repository :: git.ucc.asn.au