Most objects returned from the caldav server has one vcalendar with one subcomponent, which may be an Event, Todo, Journal or FreeBusy from the icalendar library. However, some calendar servers may also return a Timezone subcomponent. (and in addition, when there are recurrences involved, an object may have multiple recurrences given as subcomponents).
It seems like I've encountered this before and created an object._icalendar_object which looks through the subcomponents and return the first relevant subcomponent found - but then forgotten about this method, and creating code just asserting that the data we're looking for is available as self.icalendar_instance.subcomponents[0].
With this pull request, I'm removing the first underscore from the said method to indicate that it's a public method, the method has been rewritten to call on assert_ if unexpected things happen, and I'm using this method rather than subcomponents[0]
While working on this I stumbled upon some other potential bugs;
obj.data was inconsistent, sometimes it's python unicode strings, other times it's byte strings. I have fixed the code so that data should always be stored as a unicode string.
Not all code accessing self.icalendar_object would consider that the icalendar data may be expanded
self.url not always set correctly after doing a self.copy()
Another en-passant thing, "import icalendar" has been moved to the top of the file.
Most objects returned from the caldav server has one vcalendar with one subcomponent, which may be an Event, Todo, Journal or FreeBusy from the icalendar library. However, some calendar servers may also return a Timezone subcomponent. (and in addition, when there are recurrences involved, an object may have multiple recurrences given as subcomponents).
It seems like I've encountered this before and created an object._icalendar_object which looks through the subcomponents and return the first relevant subcomponent found - but then forgotten about this method, and creating code just asserting that the data we're looking for is available as self.icalendar_instance.subcomponents[0].
With this pull request, I'm removing the first underscore from the said method to indicate that it's a public method, the method has been rewritten to call on assert_ if unexpected things happen, and I'm using this method rather than subcomponents[0]
While working on this I stumbled upon some other potential bugs;
Another en-passant thing, "import icalendar" has been moved to the top of the file.