If you want to keep a chunking example in the docs, the Python snippet below works and is short enough to drop inline:
from icalendar import Calendar
from icalendar_anonymizer import anonymize
cal = Calendar.from_ical(open("calendar.ics").read())
year_cal = Calendar()
for event in cal.walk("VEVENT"):
if event["DTSTART"].dt.year == 2024:
year_cal.add_component(event)
print(anonymize(year_cal).to_ical().decode())
But probably better to keep it in python-api.rst as a worked example and link from here.
Originally posted by @SashankBhamidi in #147
Originally posted by @SashankBhamidi in #147