mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Updated sorted for 2.4 compatibility.
This commit is contained in:
parent
85807dd077
commit
ed8df0a998
@ -151,7 +151,7 @@ class Topic(callbacks.Privmsg):
|
||||
except ValueError:
|
||||
irc.error('The positions must be valid integers.')
|
||||
return
|
||||
if utils.sorted(order) != range(num):
|
||||
if sorted(order) != range(num):
|
||||
irc.error('Duplicate topic numbers cannot be specified.')
|
||||
return
|
||||
try:
|
||||
|
13
src/utils.py
13
src/utils.py
@ -394,13 +394,18 @@ def sortBy(f, L, cmp=cmp):
|
||||
for (i, elt) in enumerate(L):
|
||||
L[i] = L[i][2]
|
||||
|
||||
def sorted(iterable, *args, **kwargs):
|
||||
"""Returns a sorted list made from iterable. All other args are given to
|
||||
list.sort unchanged."""
|
||||
def sorted(iterable, cmp=None, key=None, reversed=False):
|
||||
L = list(iterable)
|
||||
L.sort(*args, **kwargs)
|
||||
if key is not None:
|
||||
sortBy(key, L, cmp=cmp)
|
||||
else:
|
||||
L.sort(cmp)
|
||||
if reversed:
|
||||
L.reverse()
|
||||
return L
|
||||
|
||||
__builtins__['sorted'] = sorted
|
||||
|
||||
def mktemp(suffix=''):
|
||||
"""Gives a decent random string, suitable for a filename."""
|
||||
import sha
|
||||
|
Loading…
Reference in New Issue
Block a user