cmp is gone in python3. Also add a sorting method to Excuse that is compatible with its __eq__/__hash__ methods. Signed-off-by: Julien Cristau <jcristau@debian.org>
@ -1623,7 +1623,7 @@ class Britney(object):
self.excuses.append(excuse)
# sort the excuses by daysold and name
self.excuses.sort(key=attrgetter('daysold', 'name'))
self.excuses.sort(key=lambda x: x.sortkey())
# extract the not considered packages, which are in the excuses but not in upgrade_me
unconsidered = [e.name for e in self.excuses if e.name not in upgrade_me]
@ -62,6 +62,11 @@ class Excuse(object):
self.reason = {}
self.htmlline = []
def sortkey(self):
if self.daysold == None:
return (-1, self.name)
return (self.daysold, self.name)
@property
def is_valid(self):
return self._is_valid
@ -144,7 +149,7 @@ class Excuse(object):
for x in self.htmlline:
res = res + "<li>" + x + "\n"
lastdep = ""
for x in sorted(self.deps, lambda x,y: cmp(x.split('/')[0], y.split('/')[0])):
for x in sorted(self.deps, key=lambda x: x.split('/')[0]):
dep = x.split('/')[0]
if dep == lastdep: continue
lastdep = dep
@ -196,7 +201,7 @@ class Excuse(object):
res.append("" + x + "")