pimutils / khal

:calendar: CLI calendar application
https://lostpackets.de/khal/
MIT License
2.61k stars 207 forks source link

khal import fails with "icalendar has no attribute windows_to_olson" #1366

Open craftyguy opened 2 days ago

craftyguy commented 2 days ago

Describe the bug khal import path/to/ics fails with: module 'icalendar' has no attribute 'windows_to_olson'

If applicable: Stack Trace

module 'icalendar' has no attribute 'windows_to_olson'
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/khal/controllers.py", line 613, in import_ics
    vevents = split_ics(ics, random_uid, conf['locale']['default_timezone'])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/khal/icalendar.py", line 59, in split_ics
    if item['TZID'] in icalendar.windows_to_olson.WINDOWS_TO_OLSON:
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'icalendar' has no attribute 'windows_to_olson'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/khal/cli.py", line 464, in import_ics
    controllers.import_ics(
  File "/usr/lib/python3.12/site-packages/khal/controllers.py", line 615, in import_ics
    raise FatalError(error)
khal.exceptions.FatalError: module 'icalendar' has no attribute 'windows_to_olson'

To Reproduce Steps to reproduce the behavior:

`khal import

Expected behavior

khal should import the ics without failing

OS, version, khal version and how you installed it:

my redacted config file ``` [view] frame = color dynamic_days = false event_view_always_visible = true [calendars] [default] highlight_event_days = true default_calendar = personal_calendar timedelta = 7d [locale] timeformat = %H:%M dateformat = %d/%m/%Y longdateformat = %d/%m/%Y datetimeformat = %d/%m/%Y %H:%M longdatetimeformat = %d/%m/%Y %H:%M local_timezone = America/Los_Angeles default_timezone = America/Los_Angeles weeknumbers = left # sunday firstweekday = 6 [keybindings] export = E ```

Additional context Here's an ics that fails, I've validated it with https://icalendar.org/validator.html :

BEGIN:VCALENDAR
VERSION:2.0
PRODID:icalendar-ruby
CALSCALE:GREGORIAN
METHOD:PUBLISH
BEGIN:VTIMEZONE
TZID:America/Los_Angeles
BEGIN:DAYLIGHT
DTSTART:20250309T030000
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3
TZNAME:PDT
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:20241103T010000
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11
TZNAME:PST
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTAMP:20241104T173109Z
UID:7b522402-7939-4648-bbbb-bbbbbbbbbbbb
DTSTART;TZID=America/Los_Angeles:20241113T110000
DTEND;TZID=America/Los_Angeles:20241113T120000
LOCATION:https://example.com/appt-aab
 bd4d868c4?origin=client
ORGANIZER;CN=Important Meeting People:mailto:hello@example.c
 om
SUMMARY:Important meeting
URL;VALUE=URI:https://example.com/appt-aab
 bd4d868c4?origin=client
END:VEVENT
END:VCALENDAR
d7415 commented 2 days ago

This is due to a breaking change in icalendar and should be fixed by #1364.