# HG changeset patch # User Paul Boddie # Date 1264719435 -3600 # Node ID e3ab5b5e9464be3d09a1578c964dc5420cf6c03c # Parent 0340bf1c9f224fce6aee499f51879b7a1af3475c Made the compareEvents function the EventPage.__cmp__ method with minor alterations. diff -r 0340bf1c9f22 -r e3ab5b5e9464 EventAggregatorSupport.py --- a/EventAggregatorSupport.py Sun Jan 24 02:55:53 2010 +0100 +++ b/EventAggregatorSupport.py Thu Jan 28 23:57:15 2010 +0100 @@ -194,6 +194,19 @@ self.body = None self.categories = None + def __cmp__(self, other): + + """ + Compare this object with 'other' using the event start and end details. + """ + + event_details1 = self.getEventDetails() + event_details2 = other.getEventDetails() + return cmp( + (event_details1["start"], event_details1["end"]), + (event_details2["start"], event_details2["end"]) + ) + def copyPage(self, page): "Copy the body of the given 'page'." @@ -551,17 +564,6 @@ return latest -def compareEvents(event1, event2): - - "Compare 'event1' and 'event2' by start and end date." - - event_details1 = event1.getEventDetails() - event_details2 = event2.getEventDetails() - return cmp( - (event_details1["start"], event_details1["end"]), - (event_details2["start"], event_details2["end"]) - ) - def getOrderedEvents(events): """ @@ -570,7 +572,7 @@ """ ordered_events = events[:] - ordered_events.sort(compareEvents) + ordered_events.sort() return ordered_events def getConcretePeriod(calendar_start, calendar_end, earliest, latest):