diff --git a/plugins/Games/plugin.py b/plugins/Games/plugin.py index 7ab02bb79..7f94cf7c7 100644 --- a/plugins/Games/plugin.py +++ b/plugins/Games/plugin.py @@ -30,7 +30,7 @@ import re import random -from itertools import imap + import supybot.utils as utils from supybot.commands import * @@ -62,7 +62,7 @@ class Games(callbacks.Plugin): For example, 2d6 will roll 2 six-sided dice; 10d10 will roll 10 ten-sided dice. """ - (dice, sides) = imap(int, m.groups()) + (dice, sides) = map(int, m.groups()) if dice > 1000: irc.error(_('You can\'t roll more than 1000 dice.')) elif sides > 100: diff --git a/plugins/Misc/plugin.py b/plugins/Misc/plugin.py index e2be33e8c..7fd39b494 100644 --- a/plugins/Misc/plugin.py +++ b/plugins/Misc/plugin.py @@ -34,7 +34,7 @@ import imp import sys import json import time -from itertools import ifilter + import supybot @@ -52,6 +52,9 @@ from supybot import commands from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('Misc') +if sys.version_info[0] < 3: + from itertools import ifilter as filter + def get_suffix(file): for suffix in imp.get_suffixes(): if file[-len(suffix[0]):] == suffix[0]: @@ -446,7 +449,7 @@ class Misc(callbacks.Plugin): predicates.setdefault('regexp', []).append(f) elif option == 'nolimit': nolimit = True - iterable = ifilter(self._validLastMsg, reversed(irc.state.history)) + iterable = filter(self._validLastMsg, reversed(irc.state.history)) if skipfirst: # Drop the first message only if our current channel is the same as # the channel we've been instructed to look at. diff --git a/setup.py b/setup.py index cdf29a3e6..ed18c0afa 100644 --- a/setup.py +++ b/setup.py @@ -150,9 +150,8 @@ try: fixer_names = ['fix_basestring', 'fix_dict', - 'fix_funcattrs', 'fix_imports', - 'fix_itertools', 'fix_itertools_imports', 'fix_long', + 'fix_long', 'fix_map', 'fix_metaclass', 'fix_methodattrs', 'fix_numliterals', 'fix_types', diff --git a/src/drivers/Socket.py b/src/drivers/Socket.py index 98be09eca..cab96264a 100644 --- a/src/drivers/Socket.py +++ b/src/drivers/Socket.py @@ -131,7 +131,7 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin): while msgs[-1] is not None: msgs.append(self.irc.takeMsg()) del msgs[-1] - self.outbuffer += ''.join(imap(str, msgs)) + self.outbuffer += ''.join(map(str, msgs)) if self.outbuffer: try: if sys.version_info[0] < 3: diff --git a/src/ircdb.py b/src/ircdb.py index 25ae3168a..e1b3cd913 100644 --- a/src/ircdb.py +++ b/src/ircdb.py @@ -150,7 +150,7 @@ class CapabilitySet(set): def __repr__(self): return '%s([%s])' % (self.__class__.__name__, - ', '.join(imap(repr, self))) + ', '.join(map(repr, self))) antiOwner = makeAntiCapability('owner') class UserCapabilitySet(CapabilitySet): diff --git a/src/ircutils.py b/src/ircutils.py index 33974fcc8..0e5aa942d 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -49,7 +49,7 @@ from cStringIO import StringIO as sio from . import utils from . import minisix -from itertools import imap + def debug(s, *args): """Prints a debug string. Most likely replaced by our logging debug.""" @@ -525,7 +525,7 @@ def unDccIP(i): L.append(i % 256) i //= 256 L.reverse() - return '.'.join(imap(str, L)) + return '.'.join(map(str, L)) class IrcString(str): """This class does case-insensitive comparison and hashing of nicks.""" diff --git a/src/utils/file.py b/src/utils/file.py index 6f68cc952..b2a698033 100644 --- a/src/utils/file.py +++ b/src/utils/file.py @@ -105,7 +105,7 @@ def nonCommentLines(fd): yield line def nonEmptyLines(fd): - return ifilter(str.strip, fd) + return filter(str.strip, fd) def nonCommentNonEmptyLines(fd): return nonEmptyLines(nonCommentLines(fd)) diff --git a/src/utils/gen.py b/src/utils/gen.py index 38f0100fd..794264766 100644 --- a/src/utils/gen.py +++ b/src/utils/gen.py @@ -38,7 +38,7 @@ import types import textwrap import traceback import collections -from itertools import imap + from . import crypt from .str import format @@ -302,7 +302,7 @@ class InsensitivePreservingDict(collections.MutableMapping): class NormalizingSet(set): def __init__(self, iterable=()): - iterable = imap(self.normalize, iterable) + iterable = map(self.normalize, iterable) super(NormalizingSet, self).__init__(iterable) def normalize(self, x): diff --git a/src/utils/iter.py b/src/utils/iter.py index 8a9e1fde0..8e84d8915 100644 --- a/src/utils/iter.py +++ b/src/utils/iter.py @@ -36,8 +36,9 @@ from itertools import * # For old plugins ifilter = filter -def ifilterfalse(p, L): - return ifilter(lambda x:not p(x), L) +def filterfalse(p, L): + return filter(lambda x:not p(x), L) +ifilterfalse = filterfalse imap = map def len(iterable): @@ -70,14 +71,14 @@ def partition(p, iterable): def any(p, iterable): """Returns true if any element in iterable satisfies predicate p.""" - for elt in ifilter(p, iterable): + for elt in filter(p, iterable): return True else: return False def all(p, iterable): """Returns true if all elements in iterable satisfy predicate p.""" - for elt in ifilterfalse(p, iterable): + for elt in filterfalse(p, iterable): return False else: return True diff --git a/src/utils/structures.py b/src/utils/structures.py index 6e8e5e371..31e8f561f 100644 --- a/src/utils/structures.py +++ b/src/utils/structures.py @@ -34,7 +34,7 @@ Data structures for Python. import time import types import collections -from itertools import imap + class RingBuffer(object): """Class to represent a fixed-size ring buffer.""" @@ -223,7 +223,7 @@ class queue(object): return False def __repr__(self): - return 'queue([%s])' % ', '.join(imap(repr, self)) + return 'queue([%s])' % ', '.join(map(repr, self)) def __getitem__(self, oidx): if len(self) == 0: @@ -300,7 +300,7 @@ class smallqueue(list): return self[0] def __repr__(self): - return 'smallqueue([%s])' % ', '.join(imap(repr, self)) + return 'smallqueue([%s])' % ', '.join(map(repr, self)) def reset(self): self[:] = []