mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-04-24 17:41:11 +00:00
Use the key= argument to sorted()
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>
This commit is contained in:
parent
c79c0848e5
commit
90f5993c4a
@ -1623,7 +1623,7 @@ class Britney(object):
|
|||||||
self.excuses.append(excuse)
|
self.excuses.append(excuse)
|
||||||
|
|
||||||
# sort the excuses by daysold and name
|
# 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
|
# 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]
|
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.reason = {}
|
||||||
self.htmlline = []
|
self.htmlline = []
|
||||||
|
|
||||||
|
def sortkey(self):
|
||||||
|
if self.daysold == None:
|
||||||
|
return (-1, self.name)
|
||||||
|
return (self.daysold, self.name)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
return self._is_valid
|
return self._is_valid
|
||||||
@ -144,7 +149,7 @@ class Excuse(object):
|
|||||||
for x in self.htmlline:
|
for x in self.htmlline:
|
||||||
res = res + "<li>" + x + "\n"
|
res = res + "<li>" + x + "\n"
|
||||||
lastdep = ""
|
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]
|
dep = x.split('/')[0]
|
||||||
if dep == lastdep: continue
|
if dep == lastdep: continue
|
||||||
lastdep = dep
|
lastdep = dep
|
||||||
@ -196,7 +201,7 @@ class Excuse(object):
|
|||||||
for x in self.htmlline:
|
for x in self.htmlline:
|
||||||
res.append("" + x + "")
|
res.append("" + x + "")
|
||||||
lastdep = ""
|
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]
|
dep = x.split('/')[0]
|
||||||
if dep == lastdep: continue
|
if dep == lastdep: continue
|
||||||
lastdep = dep
|
lastdep = dep
|
||||||
|
Loading…
x
Reference in New Issue
Block a user