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

Guido Günther agx at sigxcpu.org
Wed Jan 27 22:30:31 PST 2016


On Wed, Jan 27, 2016 at 10:01:15PM +0000, Jelmer Vernooij wrote:
> From: Jelmer Vernooij <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']
> +
> +

This has a different logi than the current behaviour (which is good)
but should be mentioned in the commit message.

ACK with this fixed.


>  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
> -        
> +


Whitespace cleanups should better be separate in the future.

Cheers,
 -- Guido


More information about the Calypso mailing list