mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +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:
|
except ValueError:
|
||||||
irc.error('The positions must be valid integers.')
|
irc.error('The positions must be valid integers.')
|
||||||
return
|
return
|
||||||
if utils.sorted(order) != range(num):
|
if sorted(order) != range(num):
|
||||||
irc.error('Duplicate topic numbers cannot be specified.')
|
irc.error('Duplicate topic numbers cannot be specified.')
|
||||||
return
|
return
|
||||||
try:
|
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):
|
for (i, elt) in enumerate(L):
|
||||||
L[i] = L[i][2]
|
L[i] = L[i][2]
|
||||||
|
|
||||||
def sorted(iterable, *args, **kwargs):
|
def sorted(iterable, cmp=None, key=None, reversed=False):
|
||||||
"""Returns a sorted list made from iterable. All other args are given to
|
|
||||||
list.sort unchanged."""
|
|
||||||
L = list(iterable)
|
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
|
return L
|
||||||
|
|
||||||
|
__builtins__['sorted'] = sorted
|
||||||
|
|
||||||
def mktemp(suffix=''):
|
def mktemp(suffix=''):
|
||||||
"""Gives a decent random string, suitable for a filename."""
|
"""Gives a decent random string, suitable for a filename."""
|
||||||
import sha
|
import sha
|
||||||
|
Loading…
Reference in New Issue
Block a user