Continue accelerating the 2to3 step (remove fix_funcattrs, fix_itertools, and fix_itertools_imports).

This commit is contained in:
Valentin Lorentz 2014-01-21 10:50:55 +01:00
parent 35a62b4e77
commit 1fbdedc7e0
10 changed files with 23 additions and 20 deletions

View File

@ -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:

View File

@ -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.

View File

@ -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',

View File

@ -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:

View File

@ -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):

View File

@ -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."""

View File

@ -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))

View File

@ -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):

View File

@ -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

View File

@ -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[:] = []