Changed reviter to reversed.

This commit is contained in:
Jeremy Fincher 2004-04-20 09:51:20 +00:00
parent 96838d0dbc
commit 9a907277c1
6 changed files with 12 additions and 16 deletions

View File

@ -411,7 +411,7 @@ class Misc(callbacks.Privmsg):
except ValueError, e:
irc.error(str(e))
return
iterable = ifilter(self._validLastMsg, reviter(irc.state.history))
iterable = ifilter(self._validLastMsg, reversed(irc.state.history))
iterable.next() # Drop the first message.
predicates = list(utils.flatten(predicates.itervalues()))
for m in iterable:

View File

@ -39,7 +39,7 @@ __revision__ = "$Id$"
__all__ = []
exported = ['ignore', 'reviter', 'window', 'group', 'sorted',
exported = ['ignore', 'reversed', 'window', 'group', 'sorted',
'partition', 'any', 'all', 'rsplit']
import new
@ -65,8 +65,8 @@ def ignore(*args, **kwargs):
"""Simply ignore the arguments sent to it."""
pass
def reviter(L):
"""Iterates through a list in reverse."""
def reversed(L):
"""Iterates through a sequence in reverse."""
for i in xrange(len(L) - 1, -1, -1):
yield L[i]

View File

@ -551,7 +551,7 @@ class Irc(IrcCommandDispatcher):
self.queueMsg(ircmsgs.ping(now))
if msg:
#log.debug(repr(msg)) # Useless!
for callback in reviter(self.callbacks):
for callback in reversed(self.callbacks):
msg = callback.outFilter(self, msg)
if msg is None:
log.debug('%s.outFilter returned None.' % callback.name())

View File

@ -205,7 +205,7 @@ class queue(object):
return elt in self.front or elt in self.back
def __iter__(self):
for elt in reviter(self.front):
for elt in reversed(self.front):
yield elt
for elt in self.back:
yield elt

View File

@ -40,6 +40,7 @@ import fix
import os
import re
import md5
import new
import sha
import types
import socket

View File

@ -36,18 +36,13 @@ from testsupport import *
import itertools
class FunctionsTest(SupyTestCase):
def testCatch(self):
def f():
raise Exception
catch(f)
def testReviter(self):
def testReversed(self):
L = range(10)
revL = list(reviter(L))
revL = list(reversed(L))
L.reverse()
self.assertEqual(L, revL, 'reviter didn\'t return reversed list')
for _ in reviter([]):
self.fail('reviter caused iteration over empty sequence')
self.assertEqual(L, revL, 'reversed didn\'t return reversed list')
for _ in reversed([]):
self.fail('reversed caused iteration over empty sequence')
def testGroup(self):
s = '1. d4 d5 2. Nf3 Nc6 3. e3 Nf6 4. Nc3 e6 5. Bd3 a6'