[Vobject] Zero-length event time

Tobias Brox t-caldav at tobixen.no
Tue Feb 10 02:42:41 CST 2015


Forwarding (with some minor edits) a report I got on the caldav library:

===

I have some problem with special events, where DTSTART = DTEND

DTSTART;TZID=Europe/Berlin:20150211T110000
DTEND;TZID=Europe/Berlin:20150211T110000

Not sure if this is valid ics but I have it in our davical server.

I get an error message:

Traceback (most recent call last):
  File "test.py", line 80, in <module>
    results = calendar.date_search(startFilter, endFilter)
  File "/usr/local/lib/python2.6/dist-packages/caldav-0.2.2-py2.6.egg/caldav/objects.py",
line 421, in date_search
    e = Event(self.client, url=href, data=data, parent=self)
  File "/usr/local/lib/python2.6/dist-packages/caldav-0.2.2-py2.6.egg/caldav/objects.py",
line 505, in __init__
    self.data = data
  File "/usr/local/lib/python2.6/dist-packages/caldav-0.2.2-py2.6.egg/caldav/objects.py",
line 553, in set_data
    self._instance = vobject.readOne(StringIO.StringIO(self._data))
  File "/usr/local/lib/python2.6/dist-packages/vobject-0.8.1c-py2.6.egg/vobject/base.py",
line 1079, in readOne
    ignoreUnreadable, allowQP).next()
  File "/usr/local/lib/python2.6/dist-packages/vobject-0.8.1c-py2.6.egg/vobject/base.py",
line 1056, in readComponents
    if transform: component.transformChildrenToNative()
  File "/usr/local/lib/python2.6/dist-packages/vobject-0.8.1c-py2.6.egg/vobject/base.py",
line 601, in transformChildrenToNative
    childArray[i].transformChildrenToNative()
  File "/usr/local/lib/python2.6/dist-packages/vobject-0.8.1c-py2.6.egg/vobject/base.py",
line 600, in transformChildrenToNative
    childArray[i]=childArray[i].transformToNative()
  File "/usr/local/lib/python2.6/dist-packages/vobject-0.8.1c-py2.6.egg/vobject/base.py",
line 122, in transformToNative
    return self.behavior.transformToNative(self)
  File "/usr/local/lib/python2.6/dist-packages/vobject-0.8.1c-py2.6.egg/vobject/icalendar.py",
line 1354, in transformToNative
    raise ParseError("DURATION must have a single duration string.")
vobject.base.ParseError: At line 14: DURATION must have a single
duration string.

I figured out that I can fix it by adding a duration of 0 hours in file:
vobject-0.8.1c-py2.6.egg/vobject/icalendar.py line 1336:


    def transformToNative(obj):
        """Turn obj.value into a datetime.timedelta."""
        if obj.isNative: return obj
        obj.isNative = True
        obj.value=str(obj.value)
        if obj.value == '':
            return obj
        else:
            if obj.value == 'P':
               # if Duration is not valid (only "P") set it to 1 hour
               obj.value = 'PT0H'
            #print "obj.value: " + obj.value
            deltalist=stringToDurations(obj.value)
            #When can DURATION have multiple durations?  For now:
            if len(deltalist) == 1:
                obj.value = deltalist[0]
                return obj
            else:
                raise ParseError("DURATION must have a single duration
string.")


-- 
Tobias Brox
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 495 bytes
Desc: not available
URL: <http://lists.skyhouseconsulting.com/pipermail/vobject/attachments/20150210/4e9f5d97/attachment.sig>


More information about the VObject mailing list