1.1 --- a/imiptools/period.py Wed Oct 28 11:56:06 2015 +0100
1.2 +++ b/imiptools/period.py Wed Oct 28 12:52:31 2015 +0100
1.3 @@ -501,20 +501,31 @@
1.4 elif freebusy[i] != period:
1.5 freebusy.insert(i, period)
1.6
1.7 +def remove_periods(freebusy, periods):
1.8 +
1.9 + "Remove from 'freebusy' the given 'periods'."
1.10 +
1.11 + for period in periods:
1.12 + i = bisect_left(freebusy, period)
1.13 + if i < len(freebusy) and freebusy[i] == period:
1.14 + del freebusy[i]
1.15 +
1.16 def remove_period(freebusy, uid, recurrenceid=None):
1.17
1.18 """
1.19 Remove from 'freebusy' all periods associated with 'uid' and 'recurrenceid'
1.20 (which if omitted causes the "parent" object's periods to be referenced).
1.21 +
1.22 + Return the removed periods.
1.23 """
1.24
1.25 - removed = False
1.26 + removed = []
1.27 i = 0
1.28 while i < len(freebusy):
1.29 fb = freebusy[i]
1.30 if fb.uid == uid and fb.recurrenceid == recurrenceid:
1.31 + removed.append(freebusy[i])
1.32 del freebusy[i]
1.33 - removed = True
1.34 else:
1.35 i += 1
1.36