From bd2e09a84bfecc5660f436d9a07b9c8713506cd6 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Thu, 26 Oct 2017 02:22:18 +0200 Subject: [PATCH] Small refactor in dav.py --- vdirsyncer/storage/dav.py | 44 ++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/vdirsyncer/storage/dav.py b/vdirsyncer/storage/dav.py index 8fafcd0..97827e8 100644 --- a/vdirsyncer/storage/dav.py +++ b/vdirsyncer/storage/dav.py @@ -792,32 +792,28 @@ class CalDAVStorage(DAVStorage): @staticmethod def _get_list_filters(components, start, end): - if components: - caldavfilter = ''' - - - {timefilter} - + caldavfilter = ''' + + + {timefilter} - ''' + + ''' - if start is not None and end is not None: - start = start.strftime(CALDAV_DT_FORMAT) - end = end.strftime(CALDAV_DT_FORMAT) + timefilter = '' - timefilter = ('' - .format(start=start, end=end)) - else: - timefilter = '' + if start is not None and end is not None: + start = start.strftime(CALDAV_DT_FORMAT) + end = end.strftime(CALDAV_DT_FORMAT) - for component in components: - yield caldavfilter.format(component=component, - timefilter=timefilter) - else: - if start is not None and end is not None: - for x in CalDAVStorage._get_list_filters(('VTODO', 'VEVENT'), - start, end): - yield x + timefilter = ('' + .format(start=start, end=end)) + if not components: + components = ('VTODO', 'VEVENT') + + for component in components: + yield caldavfilter.format(component=component, + timefilter=timefilter) def list(self): caldavfilters = list(self._get_list_filters( @@ -833,8 +829,8 @@ class CalDAVStorage(DAVStorage): # instead? # # See https://github.com/dmfs/tasks/issues/118 for backstory. - for x in DAVStorage.list(self): - yield x + yield from DAVStorage.list(self) + return data = '''