show-ics-details.py: fix error with python < 3.9

Change the pattern matching into a if/elif construct because pattern
matching is not supported on python < 3.9.

Signed-off-by: Jens Grassel <jens@wegtam.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Jens Grassel 2022-03-24 12:41:24 +01:00 committed by Robin Jarry
parent d64ceba2cc
commit 037676f7cc

View file

@ -41,21 +41,21 @@ def extract_field(cal: vobject.icalendar.VCalendar2_0, name: str) -> str:
name -- The field name.
"""
try:
match name.strip():
case 'attendees':
name = name.strip()
if name == 'attendees':
attendees = []
for attendee in cal.vevent.attendee_list:
attendees.append(remove_mailto(attendee.valueRepr()).strip())
return ', '.join(attendees)
case 'description':
elif name == 'description':
return cal.vevent.description.valueRepr().strip()
case 'dtstart':
elif name == 'dtstart':
return str(cal.vevent.dtstart.valueRepr()).strip()
case 'organizer':
elif name == 'organizer':
return remove_mailto(cal.vevent.organizer.valueRepr()).strip()
case 'summary':
elif name == 'summary':
return cal.vevent.summary.valueRepr().strip()
case _:
else:
return ''
except AttributeError:
return ''