Commit e902c393 authored by erdnaxe's avatar erdnaxe 🦋

Make ICS valid

parent e4e25f40
......@@ -14,5 +14,6 @@ selected_groups:
base_url: ''
- 'user/Calendar/example.ics'
- 'PUT_YOUR_USERNAME/Calendar/personal.ics'
- 'OTHER_USERNAME_TO_SUSCRIBE/Calendar/example.ics'
......@@ -31,9 +31,15 @@ class OnlineCalendar:
if == 'VTODO':
yield component
def get_timezone(self):
"""Return one timezone"""
for component in self.components.walk():
if == 'VTIMEZONE':
return component
def get_other_components(self):
"""Return all unrecognised components"""
for component in self.components.walk():
if not in blacklist:
......@@ -9,20 +9,32 @@ from icalendar_tools import OnlineCalendar
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
config = Configuration('config.yml')
# Create master calendar
calendar = Calendar()
calendar.add('prodid', '-//SaphSync//')
calendar.add('version', '2.0')
# Fetch online calendar and copy components
for url in config.calendars_url:
online_calendar = OnlineCalendar(url, config.login, config.password)
# Copy timezone definitions
tz = online_calendar.get_timezone()
# Copy events
for event in online_calendar.get_events():
# If it is an event in the future and in the correct group
if filter_date(event) and filter_group(event, config.selected_groups):
logging.debug('An event was added : {}'.format(event.get('summary')))
# Copy tasks
for todo in online_calendar.get_todos():
logging.debug('A task was added : {}'.format(todo.get('summary')))
# Copy other components
for component in online_calendar.get_other_components():'A unrecognised component ({}) was added : {}'.format(, component.to_ical()))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment