From 2f518cce812574990fd66ad11a6fab7660b53904 Mon Sep 17 00:00:00 2001 From: dlichtistw Date: Sun, 16 Sep 2018 22:26:20 +0200 Subject: [PATCH 1/3] Strip exception dates Build a list of exception dates and remove recurring events if their start ist contained in this list. --- icalevents/icalparser.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/icalevents/icalparser.py b/icalevents/icalparser.py index f75edde..5dfa155 100644 --- a/icalevents/icalparser.py +++ b/icalevents/icalparser.py @@ -326,8 +326,24 @@ def create_recurring_events(start, end, component): unfolded.append(current) else: break + + reduced_range = in_range(unfolded, start, end) + + exceptions = extract_exdates(component) + reduced_exceptions = [ev for ev in reduced_range if ev.start not in exceptions] - return in_range(unfolded, start, end) + return reduced_exceptions + + +def extract_exdates(component): + dates = [] + + exd_prop = component.get('exdate') + if exd_prop: + for exd_list in exd_prop: + dates.extend(exd.dt for exd in exd_list.dts if (exd)) + + return dates def generate_day_deltas_by_weekday(by_day): From 9803b5007dc39643278522e27dad848766271078 Mon Sep 17 00:00:00 2001 From: dlichtistw Date: Sun, 16 Sep 2018 22:37:23 +0200 Subject: [PATCH 2/3] Strip exception dates Don't fail for single exception dates. --- icalevents/icalparser.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/icalevents/icalparser.py b/icalevents/icalparser.py index 5dfa155..540fb59 100644 --- a/icalevents/icalparser.py +++ b/icalevents/icalparser.py @@ -6,6 +6,7 @@ from random import randint from datetime import datetime, timedelta, date from icalendar import Calendar +from icalendar.prop import vDDDLists from pytz import utc @@ -340,8 +341,11 @@ def extract_exdates(component): exd_prop = component.get('exdate') if exd_prop: - for exd_list in exd_prop: - dates.extend(exd.dt for exd in exd_list.dts if (exd)) + if isinstance(exd_prop, list): + for exd_list in exd_prop: + dates.extend(exd.dt for exd in exd_list.dts) + elif isinstance(exd_prop, vDDDLists): + dates.extend(exd.dt for exd in exd_prop.dts) return dates From ae6a21170731cd65183f36e95c56c62f3d032c06 Mon Sep 17 00:00:00 2001 From: Thomas Irgang Date: Mon, 17 Sep 2018 06:39:29 +0200 Subject: [PATCH 3/3] v0.1.8 Merge pull request #26 from dlichtistw/Fix-EXDATE --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0f25f18..04bd340 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( "pytz", "datetime", ], - version = '0.1.7', + version = '0.1.8', description = 'iCal downloader and parser', author = 'Thomas Irgang', author_email = 'thomas@irgang-la.de',