# HG changeset patch # User Paul Boddie # Date 1508534396 -7200 # Node ID 6975cdaac4a4c54debc18038ea94d3781f5330b5 # Parent 102a5f873a8b3c53faf2796770ec886c5b4ee730 Simplify the interface of the rule periods computation function. diff -r 102a5f873a8b -r 6975cdaac4a4 imiptools/data.py --- a/imiptools/data.py Fri Oct 20 22:52:13 2017 +0200 +++ b/imiptools/data.py Fri Oct 20 23:19:56 2017 +0200 @@ -1107,11 +1107,11 @@ return RecurringPeriod(start, end, tzid, "RRULE", attr) -def get_rule_periods(rrule, start, duration, attr, tzid, end, inclusive=False): +def get_rule_periods(rrule, main_period, tzid, end, inclusive=False): """ - Return periods for the given 'rrule', employing the 'start', 'duration', - datetime 'attr' and 'tzid'. + Return periods for the given 'rrule', employing the 'main_period' and + 'tzid'. The specified 'end' datetime indicates the end of the window for which periods shall be computed. @@ -1120,6 +1120,10 @@ will be included. """ + start = main_period.get_start() + attr = main_period.get_start_attr() + duration = main_period.get_duration() + parameters = rrule and get_parameters(rrule) selector = get_rule(start, rrule) @@ -1167,9 +1171,6 @@ main_period = obj.get_main_period(tzid) - dtstart = main_period.get_start() - dtstart_attr = main_period.get_start_attr() - # Attempt to get time zone details from the object, using the supplied zone # only as a fallback. @@ -1191,9 +1192,8 @@ selection_period = Period(start, None) periods = [] - for period in get_rule_periods(rrule, dtstart, - main_period.get_duration(), dtstart_attr, obj_tzid or tzid, end, - inclusive): + for period in get_rule_periods(rrule, main_period, obj_tzid or tzid, + end, inclusive): # Filter out periods before the start.