diff --git a/library/calendar_sync.py b/library/calendar_sync.py index 7493bbf..42e1145 100644 --- a/library/calendar_sync.py +++ b/library/calendar_sync.py @@ -41,26 +41,26 @@ def sync_ics_to_caldav(module): module.params['source_user'], module.params['source_password'] ) - + target_cal = connect_caldav( module.params['target_url'], module.params['target_user'], module.params['target_password'], module.params['verify_ssl'] ) - + existing_events = { - event.icalendar_component.uid.value: event # Korrektur hier + event.icalendar_component.uid.value: event for event in target_cal.events() } - + changed = False results = {'added': [], 'updated': [], 'removed': []} - -for vevent in ics_events: - uid = str(vevent.uid.value) # Korrektur hier + + for vevent in ics_events: + uid = str(vevent.uid.value) ical_data = vevent.serialize() - + if uid not in existing_events: target_cal.add_event(ical_data) results['added'].append(uid) @@ -70,13 +70,13 @@ for vevent in ics_events: existing_events[uid].save() results['updated'].append(uid) changed = True - + if module.params['purge']: for uid in set(existing_events.keys()) - {str(e.uid.value) for e in ics_events}: existing_events[uid].delete() results['removed'].append(uid) changed = True - + return changed, results def run_module():