import vobject
+ruleConfig = {}
+ruleConfig["defaultTZ"] = "UTC"
+
def facebookOrganiser(cal):
'''Adds organiser details to the body of facebook calendars.'''
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",
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
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)
except AttributeError: continue
return cal
-