Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot decode 'TRIGGER' item #215

Open
JSpiner opened this issue Feb 21, 2017 · 1 comment
Open

Cannot decode 'TRIGGER' item #215

JSpiner opened this issue Feb 21, 2017 · 1 comment

Comments

@JSpiner
Copy link

JSpiner commented Feb 21, 2017

blow ics file, cannot decode 'TRIGGER' item.


BEGIN:VCALENDAR
PRODID:-//NHN Corp//Naver Calendar 1.0//KO
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
BEGIN:VTIMEZONE
TZID:Asia/Seoul
TZURL:http://tzurl.org/zoneinfo-outlook/Asia/Seoul
X-LIC-LOCATION:Asia/Seoul
BEGIN:STANDARD
TZOFFSETFROM:+0900
TZOFFSETTO:+0900
TZNAME:KST
DTSTART:19700101T000000
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20110916T015234Z
LAST-MODIFIED:20120829T235500Z
DTSTAMP:20170221T080255Z
UID:testtesttesttest@naver.com
TRANSP:TRANSPARENT
STATUS:TENTATIVE
SEQUENCE:0
SUMMARY:mybirthday
DESCRIPTION:
DTSTART;VALUE=DATE:19920323
DTEND;VALUE=DATE:19920324
CLASS:PUBLIC
LOCATION:
PRIORITY:5
RRULE:FREQ=YEARLY;INTERVAL=1
X-NAVER-STICKER-ID:006
X-NAVER-STICKER-POS:0
X-NAVER-STICKER-DEFAULT-POS:1
X-NAVER-CATEGORY-ID:0
X-NAVER-ANNIVERSARY:TRUE
X-NAVER-SCHEDULE-DETAIL-VIEW-URL:https://caldav.test.test/test
X-NAVER-WRITER-ID:kkk1140
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT12H
DESCRIPTION:
END:VALARM
END:VEVENT
END:VCALENDAR

I'm trying to parse every 'VEVENT' data.

def parseICS(ics):
    dictResult = {}
    dictResult['VEVENT'] = {}
    print(ics)
    calendar = Calendar.from_ical(ics)
    for component in calendar.walk():
        if component.name == "VEVENT":
            for row in component.property_items():
                print(str(row) + " " + str(component.get(row[0])))
                if isinstance(row[1], icalendar.prop.vDDDTypes): 
                    result = component.decoded(row[0]) # <- error in here!
                else:
                    result = str(row[1])
            dictResult['VEVENT'][row[0]] = result
    return dictResult

below is my error

('TRIGGER', <icalendar.prop.vDDDTypes object at 0x7f0a45697a90>) None
Traceback (most recent call last):
  File "main.py", line 29, in <module>
    eventDataList = calendars[0].getCalendarData(eventList)
  File "/home/jspiner/soma/python-caldavclient/caldavclient/caldavclient.py", line 228, in getCalendarData
    eventData = response.find("propstat").find("prop").find("calendar-data").text()
  File "/home/jspiner/soma/python-caldavclient/caldavclient/caldavclient.py", line 304, in __init__
    self.eventData = util.parseICS(eventData)
  File "/home/jspiner/soma/python-caldavclient/caldavclient/util.py", line 50, in parseICS
    result = component.decoded(row[0])
  File "/home/jspiner/soma/python-caldavclient/env/lib/python3.5/site-packages/icalendar/cal.py", line 240, in decoded
    raise KeyError(name)
KeyError: 'TRIGGER'

I think it cannot decode TRIGGER vDDDTypes object.

@natashamm
Copy link
Contributor

natashamm commented May 26, 2024

There is a problem with how the function (parseICS) is written and using decoded.

In this line when we get the error:

result = component.decoded(row[0]) # <- error in here!

component is an Event
row[0] is Trigger (not a property in Event), so we would want there to be an error.

Edit: so this issue can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants