Support overwriting details for all events

Useful for calendars which contain events of the same kind and the same location only but need some adjustments to improve the usability of the calendar.
This commit is contained in:
Fabian Müller 2025-02-05 23:38:35 +01:00
parent af33203932
commit 54222eb8cc

View File

@ -21,6 +21,9 @@ class ConfiguredCalendar(NamedTuple):
name: str
url: str
default_color: str = None
overwrite_summary: str = None
overwrite_description: str = None
overwrite_location: str = None
class CalendarClient:
@ -84,6 +87,11 @@ class CombinedCalendarClient:
except KeyError:
default_color = None
# if the user wishes to overwrite some data on every item in a calendar, we should do so
overwrite_summary = configured_calendar.overwrite_summary
overwrite_description = configured_calendar.overwrite_description
overwrite_location = configured_calendar.overwrite_location
# we don't copy anything but events from the
for event in cal.walk("VEVENT"):
# if no color has been configured in the event, we
@ -91,6 +99,15 @@ class CombinedCalendarClient:
if "color" not in event:
event["color"] = default_color
if overwrite_summary:
event["SUMMARY"] = overwrite_summary
if overwrite_description:
event["DESCRIPTION"] = overwrite_description
if overwrite_location:
event["LOCATION"] = overwrite_location
combined_calendar.add_component(event)
return combined_calendar