Fixed uptime sorting.

This commit is contained in:
Jeremy Fincher 2003-11-25 09:45:01 +00:00
parent a3aeaee2b0
commit 6d3cb48c51
2 changed files with 6 additions and 5 deletions

View File

@ -1,3 +1,7 @@
* Fixed sorting in Status' uptime database.
* Updated the Gameknot tests for expired games.
* Added a 'server' attribute to Irc objects to unify the way to
access such information.

View File

@ -84,16 +84,13 @@ class UptimeDB(object):
def top(self, n=3):
def decorator(t):
if t[1] is None:
return 0.0
else:
t[1] - t[0]
return t[1] - t[0]
def invertCmp(cmp):
def f(x, y):
return -cmp(x, y)
return f
def notNone(t):
return t[1] is not None
return t[1] is not None and t[0] != 0
utils.sortBy(decorator, self.uptimes, cmp=invertCmp(cmp))
return list(islice(ifilter(notNone, self.uptimes), n))