Disable Outlook Rules for Facebook
[frenchie/icalparse.git] / parserrules.py
index 973aa45..4ba71e8 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,12 +54,16 @@ def whatPrivacy(cal):
 
        for event in cal.vevent_list:
                if event.contents.has_key(u'class'):
-                       getattr(event, 'class').value = "PUBLIC"
+                       # Bit of a hack as class is a reserved word in python
+                       del event.contents[u'class']
+                       event.add('class').value = "PUBLIC"
 
        return cal
 
 def dropAttributes(cal):
        '''Removing unwanted metadata'''
+       if "facebook" in ruleConfig:
+               if ruleConfig["facebook"] == True: return cal
 
        eventBlacklist = [x.lower() for x in [
                "X-ALT-DESC",
@@ -98,12 +105,13 @@ def dropAttributes(cal):
 
 def exDate(cal):
        '''Replacing multi-value EXDATES with multiple single-value EXDATES'''
+       if "facebook" in ruleConfig:
+               if ruleConfig["facebook"] == True: return 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
@@ -121,12 +129,13 @@ def exDate(cal):
        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)
@@ -159,4 +168,3 @@ def unwantedParams(cal):
                        except AttributeError: continue
 
        return cal
-

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