mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Changed reviter to reversed.
This commit is contained in:
parent
96838d0dbc
commit
9a907277c1
@ -411,7 +411,7 @@ class Misc(callbacks.Privmsg):
|
|||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
return
|
return
|
||||||
iterable = ifilter(self._validLastMsg, reviter(irc.state.history))
|
iterable = ifilter(self._validLastMsg, reversed(irc.state.history))
|
||||||
iterable.next() # Drop the first message.
|
iterable.next() # Drop the first message.
|
||||||
predicates = list(utils.flatten(predicates.itervalues()))
|
predicates = list(utils.flatten(predicates.itervalues()))
|
||||||
for m in iterable:
|
for m in iterable:
|
||||||
|
@ -39,7 +39,7 @@ __revision__ = "$Id$"
|
|||||||
|
|
||||||
__all__ = []
|
__all__ = []
|
||||||
|
|
||||||
exported = ['ignore', 'reviter', 'window', 'group', 'sorted',
|
exported = ['ignore', 'reversed', 'window', 'group', 'sorted',
|
||||||
'partition', 'any', 'all', 'rsplit']
|
'partition', 'any', 'all', 'rsplit']
|
||||||
|
|
||||||
import new
|
import new
|
||||||
@ -65,8 +65,8 @@ def ignore(*args, **kwargs):
|
|||||||
"""Simply ignore the arguments sent to it."""
|
"""Simply ignore the arguments sent to it."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def reviter(L):
|
def reversed(L):
|
||||||
"""Iterates through a list in reverse."""
|
"""Iterates through a sequence in reverse."""
|
||||||
for i in xrange(len(L) - 1, -1, -1):
|
for i in xrange(len(L) - 1, -1, -1):
|
||||||
yield L[i]
|
yield L[i]
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ class Irc(IrcCommandDispatcher):
|
|||||||
self.queueMsg(ircmsgs.ping(now))
|
self.queueMsg(ircmsgs.ping(now))
|
||||||
if msg:
|
if msg:
|
||||||
#log.debug(repr(msg)) # Useless!
|
#log.debug(repr(msg)) # Useless!
|
||||||
for callback in reviter(self.callbacks):
|
for callback in reversed(self.callbacks):
|
||||||
msg = callback.outFilter(self, msg)
|
msg = callback.outFilter(self, msg)
|
||||||
if msg is None:
|
if msg is None:
|
||||||
log.debug('%s.outFilter returned None.' % callback.name())
|
log.debug('%s.outFilter returned None.' % callback.name())
|
||||||
|
@ -205,7 +205,7 @@ class queue(object):
|
|||||||
return elt in self.front or elt in self.back
|
return elt in self.front or elt in self.back
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
for elt in reviter(self.front):
|
for elt in reversed(self.front):
|
||||||
yield elt
|
yield elt
|
||||||
for elt in self.back:
|
for elt in self.back:
|
||||||
yield elt
|
yield elt
|
||||||
|
@ -40,6 +40,7 @@ import fix
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import md5
|
import md5
|
||||||
|
import new
|
||||||
import sha
|
import sha
|
||||||
import types
|
import types
|
||||||
import socket
|
import socket
|
||||||
|
@ -36,18 +36,13 @@ from testsupport import *
|
|||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
class FunctionsTest(SupyTestCase):
|
class FunctionsTest(SupyTestCase):
|
||||||
def testCatch(self):
|
def testReversed(self):
|
||||||
def f():
|
|
||||||
raise Exception
|
|
||||||
catch(f)
|
|
||||||
|
|
||||||
def testReviter(self):
|
|
||||||
L = range(10)
|
L = range(10)
|
||||||
revL = list(reviter(L))
|
revL = list(reversed(L))
|
||||||
L.reverse()
|
L.reverse()
|
||||||
self.assertEqual(L, revL, 'reviter didn\'t return reversed list')
|
self.assertEqual(L, revL, 'reversed didn\'t return reversed list')
|
||||||
for _ in reviter([]):
|
for _ in reversed([]):
|
||||||
self.fail('reviter caused iteration over empty sequence')
|
self.fail('reversed caused iteration over empty sequence')
|
||||||
|
|
||||||
def testGroup(self):
|
def testGroup(self):
|
||||||
s = '1. d4 d5 2. Nf3 Nc6 3. e3 Nf6 4. Nc3 e6 5. Bd3 a6'
|
s = '1. d4 d5 2. Nf3 Nc6 3. e3 Nf6 4. Nc3 e6 5. Bd3 a6'
|
||||||
|
Loading…
Reference in New Issue
Block a user