# HG changeset patch # User Paul Boddie # Date 1439396604 -7200 # Node ID fcd0670d31608857323ed8e88fbb184554aeac4e # Parent f8b21bbd82bfee1c42f9b9c67a2a91ee1f4e6011 Made free/busy period comparisons more comprehensive, avoiding equality results for combinations of recurrences and/or their parent events. Prevented the insertion of duplicate periods when adding free/busy periods. diff -r f8b21bbd82bf -r fcd0670d3160 imiptools/period.py --- a/imiptools/period.py Tue Aug 11 23:53:54 2015 +0200 +++ b/imiptools/period.py Wed Aug 12 18:23:24 2015 +0200 @@ -196,7 +196,7 @@ result = PeriodBase.__cmp__(self, other) if result == 0 and isinstance(other, FreeBusyPeriod): - return cmp(self.uid, other.uid) + return cmp((self.uid, self.recurrenceid), (other.uid, other.recurrenceid)) else: return result @@ -271,7 +271,11 @@ "Insert into 'freebusy' the given 'period'." - insort_left(freebusy, period) + i = bisect_left(freebusy, period) + if i == len(freebusy): + freebusy.append(period) + elif freebusy[i] != period: + freebusy.insert(i, period) def remove_period(freebusy, uid, recurrenceid=None):