tobixen / calendar-cli

Simple command-line CalDav client, for adding and browsing calendar items, todo list items
GNU General Public License v3.0
247 stars 23 forks source link

Mutliple BEGIN:VCALENDAR in ical output #97

Open tobixen opened 1 year ago

tobixen commented 1 year ago

Filing this on behalf of @maltimore ... I hope you will find this "message" ... and sorry for not paying much attention to my IRC session nowadays. I found this in my log:

2023-01-01 09:44 < maltimore> Hi! This is my first time using IRC. Can you confirm that you see this message?
2023-01-01 09:58 < maltimore> I'm going to post my question anyways, and might copy it to github later if this doesn't work ;)
2023-01-01 10:01 < maltimore> So I'm using calendar-cli to download my calendar from a vcal server. This file should then be read with the python icalendar package, namely with Calendar.from_ical method. But when I do that I get an error  message essentially complaining that there are multiple BEGIN:VCALENDAR components in the ical file I get from calendar-cli. So my question is, is it icalendar-compliant to have multiple BEGIN:VCALENAR blocks in an ical file?
2023-01-01 10:02 < maltimore> if I manually delete BEGIN:VCALENDAR and END:VCALENDAR lines such that there is only one begin and one end, then it works fine

First of all, if you want to pull something out from the calendar and then load it into the python icalendar package, then you should not be using calendar-cli, then you should be using the caldav library directly. After fetching an object using the caldav library, you can use the properties obj.icalendar_object or obj.icalendar_component to get the icalendar object out.

When fetching multiple objects from a caldav server, it will always encapsulate each object with BEGIN:VCALENDAR and END:VCALENDAR, and the full data file cannot be loaded into the icalendar library without either splitting it up or removing the excess begin/end markers first. I'm too lazy to check the RFCs now, but I'm pretty confident that this is in accordance with the caldav RFC (RFC 4791). I have no idea if the icalendar RFC (RFC 5545) allows or disallows several VCALENDAR objects in the same file, but I would be surprised RFC 5545 disallows the behaviour that is mandated in RFC 4791 :-)