[Calypso] [PATCH] Remove DURATION if both DURATION and DTEND are present on a VEVENT.

Jelmer Vernooij jelmer at jelmer.uk
Wed Jan 27 14:01:15 PST 2016


From: Jelmer Vernooń≥ <jelmer at jelmer.uk>

See RFC5545, section 3.6.1.
---
 calypso/webdav.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/calypso/webdav.py b/calypso/webdav.py
index f6b84ab..0acfdf0 100644
--- a/calypso/webdav.py
+++ b/calypso/webdav.py
@@ -58,6 +58,14 @@ def find_vobject_value(vobject, name):
             return value
     return None
 
+
+def sanitize_vevent(ve):
+    # Check for events with both dtend and duration entries and
+    # delete the duration one
+    if ve.contents.has_key('dtend') and ve.contents.has_key('duration'):
+        del ve.contents['duration']
+
+
 class Item(object):
 
     """Internal item. Wraps a vObject"""
@@ -514,10 +522,7 @@ class Collection(object):
 
                     events = new_ics.vevent_list
                     for ve in events:
-                        # Check for events with both dtstart and duration entries and
-                        # delete the duration one
-                        if ve.contents.has_key('dtstart') and ve.contents.has_key('duration'):
-                            del ve.contents['duration']
+                        sanitize_vevent(ve)
                         new_ics.vevent_list = [ve]
                         new_item = Item(new_ics.serialize().decode('utf-8'), None, path)
                         self.import_item(new_item, path)
@@ -528,7 +533,7 @@ class Collection(object):
         except Exception, ex:
             self.log.exception("Failed to import: %s", path)
             return False
-        
+
     def write(self, headers=None, items=None):
         return True
 
-- 
2.7.0



More information about the Calypso mailing list