def load(self): """ Load the event from the caldav server. """ r = self.client.request(self.url.path) self.data = vcal.fix(r.raw) return self
def _set_data(self, data): if type(data).__module__.startswith("vobject"): self._data = data self._instance = data else: self._data = vcal.fix(data) self._instance = vobject.readOne(to_unicode(self._data)) return self
def load(self): """ Load the object from the caldav server. """ r = self.client.request(self.url) if r.status == 404: raise error.NotFoundError(errmsg(r)) self.data = vcal.fix(r.raw) return self
def load(self): """ Load the event from the caldav server. """ r = self.client.request(self.url.path) if r.status == 404: raise error.NotFoundError(r.raw) self.data = vcal.fix(r.raw) return self
def _set_data(self, data): if type(data).__module__.startswith("icalendar"): self._data = data self._instance = data else: self._data = vcal.fix(data) self._instance = icalendar.Calendar.from_ical( to_unicode(self._data)) return self
def test_vcal_fixups(self): """ There is an obscure function lib.vcal that attempts to fix up known ical standard breaches from various calendar servers. """ broken_ical = [ ## This first one contains duplicated DTSTART in the event data """BEGIN:VCALENDAR X-EXPANDED:True X-MASTER-DTSTART:20200517T060000Z X-MASTER-RRULE:FREQ=YEARLY BEGIN:VEVENT DTSTAMP:20210205T101751Z UID:[email protected] DTSTAMP:20200516T060000Z SUMMARY:Do the needful DTSTART:20210517T060000Z DTEND:20210517T230000Z RECURRENCE-ID:20210517T060000Z END:VEVENT BEGIN:VEVENT DTSTAMP:20210205T101751Z UID:[email protected] DTSTAMP:20200516T060000Z SUMMARY:Do the needful DTSTART:20220517T060000Z DTEND:20220517T230000Z RECURRENCE-ID:20220517T060000Z END:VEVENT BEGIN:VEVENT DTSTAMP:20210205T101751Z UID:[email protected] DTSTAMP:20200516T060000Z SUMMARY:Do the needful DTSTART:20230517T060000Z DTEND:20230517T230000Z RECURRENCE-ID:20230517T060000Z END:VEVENT END:VCALENDAR""" ] ## todo: add more broken ical here for ical in broken_ical: ## This should raise error assert_raises(vobject.base.ValidateError, vobject.readOne(ical).serialize) ## This should not raise error vobject.readOne(vcal.fix(ical)).serialize()
def _set_data(self, data): ## The __init__ takes a data attribute, and it should be allowable to ## set it to an vobject object or an icalendar object, hence we should ## do type checking on the data (TODO: but should probably use ## isinstance rather than this kind of logic if type(data).__module__.startswith("vobject"): self._set_vobject_instance(data) return self if type(data).__module__.startswith("icalendar"): self._set_icalendar_instance(data) return self self._data = vcal.fix(data) self._vobject_instance = None self._icalendar_instance = None return self
def set_data(self, data): self._data = vcal.fix(data) self._instance = vobject.readOne(StringIO.StringIO(self._data)) return self
def _set_data(self, data): self._data = vcal.fix(data) self._instance = vobject.readOne(io.StringIO(to_unicode(self._data))) return self
def _set_data(self, data): self._data = vcal.fix(data) self._instance = vobject.readOne(self._data) return self