#1087998 khal traces back when importing an ical file

Package:
khal
Source:
khal
Submitter:
Sebastian Reichel
Date:
2024-11-21 16:48:02 UTC
Severity:
normal
Tags:
#1087998#5
Date:
2024-11-21 16:45:17 UTC
From:
To:
Dear Maintainer,

I see the following traceback when trying to do 'khal -v DEBUG import <ical-file>':
-------------------------------------------------------------------------------
module 'icalendar' has no attribute 'windows_to_olson'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/khal/controllers.py", line 613, in import_ics
    vevents = split_ics(ics, random_uid, conf['locale']['default_timezone'])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-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'
-------------------------------------------------------------------------------

Apparently python3-icalendar recently moved windows_to_olson from
icalendar.windows_to_olson to icalendar.timezone.windows_to_olson.
In Debian python3-icalendar migrated from 5.x to 6.x some days ago
bring in this change.

The following local modification fixed the issue for me:
------------------------------------------------------------------------------- --- a/usr/lib/python3/dist-packages/khal/icalendar.py 2024-11-21 17:42:30.603815639 +0100 +++ b/usr/lib/python3/dist-packages/khal/icalendar.py 2024-11-21 17:29:42.814434966 +0100 @@ -56,8 +56,8 @@ # Standard Time' for 'Pacific/Auckland' in Olson format), we convert any # Windows format timezones to Olson. if item.name == 'VTIMEZONE': - if item['TZID'] in icalendar.windows_to_olson.WINDOWS_TO_OLSON: - key = icalendar.windows_to_olson.WINDOWS_TO_OLSON[item['TZID']] + if item['TZID'] in icalendar.timezone.windows_to_olson.WINDOWS_TO_OLSON: + key = icalendar.timezone.windows_to_olson.WINDOWS_TO_OLSON[item['TZID']] else: key = item['TZID'] tzs[key] = item ------------------------------------------------------------------------------- Greetings,