diff --git a/plugins/Admin/plugin.py b/plugins/Admin/plugin.py index c71afcdf5..4c8411695 100644 --- a/plugins/Admin/plugin.py +++ b/plugins/Admin/plugin.py @@ -351,7 +351,7 @@ class Admin(callbacks.Plugin): """ # XXX Add the expirations. if ircdb.ignores.hostmasks: - irc.reply(format('%L', (map(repr,ircdb.ignores.hostmasks)))) + irc.reply(format('%L', (list(map(repr,ircdb.ignores.hostmasks))))) else: irc.reply(_('I\'m not currently globally ignoring anyone.')) list = wrap(list) diff --git a/plugins/Aka/plugin.py b/plugins/Aka/plugin.py index 9b943f63a..e695b939e 100644 --- a/plugins/Aka/plugin.py +++ b/plugins/Aka/plugin.py @@ -212,7 +212,7 @@ class RecursiveAlias(AkaError): dollarRe = re.compile(r'\$(\d+)') def findBiggestDollar(alias): dollars = dollarRe.findall(alias) - dollars = map(int, dollars) + dollars = list(map(int, dollars)) dollars.sort() if dollars: return dollars[-1] @@ -222,7 +222,7 @@ def findBiggestDollar(alias): atRe = re.compile(r'@(\d+)') def findBiggestAt(alias): ats = atRe.findall(alias) - ats = map(int, ats) + ats = list(map(int, ats)) ats.sort() if ats: return ats[-1] @@ -259,15 +259,15 @@ class Aka(callbacks.Plugin): def listCommands(self): channel = dynamic.channel or 'global' - return list(set(map(callbacks.formatCommand, + return list(set(list(map(callbacks.formatCommand, self._db.get_aka_list(channel) + - self._db.get_aka_list('global')) + + self._db.get_aka_list('global'))) + ['add', 'remove', 'lock', 'unlock', 'importaliasdatabase'])) def getCommand(self, args, check_other_plugins=True): canonicalName = callbacks.canonicalName # All the code from here to the 'for' loop is copied from callbacks.py - assert args == map(canonicalName, args) + assert args == list(map(canonicalName, args)) first = args[0] for cb in self.cbs: if first == cb.canonicalName(): @@ -302,7 +302,7 @@ class Aka(callbacks.Plugin): args = getArgs(args, required=biggestDollar, optional=biggestAt, wildcard=wildcard) max_len = conf.supybot.reply.maximumLength() - args = list(map(lambda x:x[:max_len], args)) + args = list([x[:max_len] for x in args]) def regexpReplace(m): idx = int(m.group(1)) return args[idx-1] @@ -512,7 +512,7 @@ class Aka(callbacks.Plugin): if errors: irc.error(format(_('Error occured when importing the %n: %L'), (len(errors), 'following', 'command'), - map(lambda x:'%s (%s)' % x, errors.items()))) + ['%s (%s)' % x for x in errors.items()])) else: irc.replySuccess() importaliasdatabase = wrap(importaliasdatabase, ['owner']) diff --git a/plugins/Alias/plugin.py b/plugins/Alias/plugin.py index 136259f63..d5d3084f3 100644 --- a/plugins/Alias/plugin.py +++ b/plugins/Alias/plugin.py @@ -87,7 +87,7 @@ class RecursiveAlias(AliasError): dollarRe = re.compile(r'\$(\d+)') def findBiggestDollar(alias): dollars = dollarRe.findall(alias) - dollars = map(int, dollars) + dollars = list(map(int, dollars)) dollars.sort() if dollars: return dollars[-1] @@ -97,7 +97,7 @@ def findBiggestDollar(alias): atRe = re.compile(r'@(\d+)') def findBiggestAt(alias): ats = atRe.findall(alias) - ats = map(int, ats) + ats = list(map(int, ats)) ats.sort() if ats: return ats[-1] @@ -179,7 +179,7 @@ def makeNewAlias(name, alias): args = getArgs(args, required=biggestDollar, optional=biggestAt, wildcard=wildcard) max_len = conf.supybot.reply.maximumLength() - args = list(map(lambda x:x[:max_len], args)) + args = list([x[:max_len] for x in args]) def regexpReplace(m): idx = int(m.group(1)) return args[idx-1] diff --git a/plugins/Channel/plugin.py b/plugins/Channel/plugin.py index 9a32d8b4f..44020c1cb 100644 --- a/plugins/Channel/plugin.py +++ b/plugins/Channel/plugin.py @@ -667,7 +667,7 @@ class Channel(callbacks.Plugin): irc.reply(s) else: L = sorted(c.ignores) - irc.reply(utils.str.commaAndify(map(repr, L))) + irc.reply(utils.str.commaAndify(list(map(repr, L)))) list = wrap(list, ['op']) class capability(callbacks.Commands): diff --git a/plugins/ChannelStats/plugin.py b/plugins/ChannelStats/plugin.py index e2b3e6fec..ee7d5de0a 100644 --- a/plugins/ChannelStats/plugin.py +++ b/plugins/ChannelStats/plugin.py @@ -135,7 +135,7 @@ class StatsDB(plugins.ChannelUserDB): return v.values() def deserialize(self, channel, id, L): - L = map(int, L) + L = list(map(int, L)) if id == 'channelStats': return ChannelStat(*L) else: diff --git a/plugins/Games/plugin.py b/plugins/Games/plugin.py index 7f94cf7c7..1ab43e628 100644 --- a/plugins/Games/plugin.py +++ b/plugins/Games/plugin.py @@ -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) = map(int, m.groups()) + (dice, sides) = list(map(int, m.groups())) if dice > 1000: irc.error(_('You can\'t roll more than 1000 dice.')) elif sides > 100: diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index 17d033e1c..a42e72828 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -143,7 +143,7 @@ class Google(callbacks.PluginRegexp): results.append(url) if sys.version_info[0] < 3: repl = lambda x:x if isinstance(x, unicode) else unicode(x, 'utf8') - results = map(repl, results) + results = list(map(repl, results)) if not results: return [_('No matches found.')] elif onetoone: diff --git a/plugins/Karma/plugin.py b/plugins/Karma/plugin.py index 3d1a46d94..3e4370a4a 100644 --- a/plugins/Karma/plugin.py +++ b/plugins/Karma/plugin.py @@ -88,12 +88,12 @@ class SqliteKarmaDB(object): if len(results) == 0: return None else: - return map(int, results[0]) + return list(map(int, results[0])) def gets(self, channel, things): db = self._getDb(channel) cursor = db.cursor() - normalizedThings = dict(list(zip(map(lambda s: s.lower(), things), things))) + normalizedThings = dict(list(zip([s.lower() for s in things], things))) criteria = ' OR '.join(['normalized=?'] * len(normalizedThings)) sql = """SELECT name, added-subtracted FROM karma WHERE %s ORDER BY added-subtracted DESC""" % criteria diff --git a/plugins/Lart/plugin.py b/plugins/Lart/plugin.py index aed197614..4bc3f5ee3 100644 --- a/plugins/Lart/plugin.py +++ b/plugins/Lart/plugin.py @@ -56,7 +56,7 @@ class Lart(plugins.ChannelIdDatabasePlugin): only necessary if the message isn't sent in the channel itself. """ if ' for ' in text: - (target, reason) = map(str.strip, text.split(' for ', 1)) + (target, reason) = list(map(str.strip, text.split(' for ', 1))) else: (target, reason) = (text, '') if id is not None: diff --git a/plugins/Math/plugin.py b/plugins/Math/plugin.py index d23566b29..123f4b0ff 100644 --- a/plugins/Math/plugin.py +++ b/plugins/Math/plugin.py @@ -308,7 +308,7 @@ class Math(callbacks.Plugin): if len(stack) == 1: irc.reply(str(self._complexToString(complex(stack[0])))) else: - s = ', '.join(map(self._complexToString, map(complex, stack))) + s = ', '.join(map(self._complexToString, list(map(complex, stack)))) irc.reply(_('Stack: [%s]') % s) @internationalizeDocstring diff --git a/plugins/MessageParser/plugin.py b/plugins/MessageParser/plugin.py index 0ad7160aa..825502959 100644 --- a/plugins/MessageParser/plugin.py +++ b/plugins/MessageParser/plugin.py @@ -161,7 +161,7 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): cursor.execute("SELECT regexp, action FROM triggers") # Fetch results and prepend channel name or 'global'. This # prevents duplicating the following lines. - results.extend(map(lambda x: (channel,)+x, cursor.fetchall())) + results.extend([(channel,)+x for x in cursor.fetchall()]) if len(results) == 0: return max_triggers = self.registryValue('maxTriggers', channel) @@ -206,7 +206,7 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): cursor.execute("SELECT id, usage_count, locked FROM triggers WHERE regexp=?", (regexp,)) results = cursor.fetchall() if len(results) != 0: - (id, usage_count, locked) = map(int, results[0]) + (id, usage_count, locked) = list(map(int, results[0])) else: locked = 0 usage_count = 0 @@ -252,7 +252,7 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): cursor.execute(sql, (regexp,)) results = cursor.fetchall() if len(results) != 0: - (id, locked) = map(int, results[0]) + (id, locked) = list(map(int, results[0])) else: irc.error(_('There is no such regexp trigger.')) return diff --git a/plugins/Misc/plugin.py b/plugins/Misc/plugin.py index 7fd39b494..28219fbdd 100644 --- a/plugins/Misc/plugin.py +++ b/plugins/Misc/plugin.py @@ -285,7 +285,7 @@ class Misc(callbacks.Plugin): You may also want to use the 'list' command to list all available plugins and commands. """ - command = map(callbacks.canonicalName, command) + command = list(map(callbacks.canonicalName, command)) (maxL, cbs) = irc.findCallbacksForArgs(command) if maxL == command: if len(cbs) > 1: diff --git a/plugins/MoobotFactoids/plugin.py b/plugins/MoobotFactoids/plugin.py index e1f8bb5cc..cff4186ad 100755 --- a/plugins/MoobotFactoids/plugin.py +++ b/plugins/MoobotFactoids/plugin.py @@ -54,9 +54,9 @@ class OptionList(object): return '(%s' % ''.join(ret) #) elif token == ')': if '|' in ret: - L = map(''.join, + L = list(map(''.join, utils.iter.split('|'.__eq__, ret, - yieldEmpty=True)) + yieldEmpty=True))) return utils.iter.choice(L) else: return '(%s)' % ''.join(ret) @@ -377,7 +377,7 @@ class MoobotFactoids(callbacks.Plugin): tokens) s = _('Missing an \'is\' or \'_is_\'.') raise ValueError(s) - (key, newfact) = map(' '.join, utils.iter.split(p, tokens, maxsplit=1)) + (key, newfact) = list(map(' '.join, utils.iter.split(p, tokens, maxsplit=1))) key = self._sanitizeKey(key) return (key, newfact) @@ -397,8 +397,8 @@ class MoobotFactoids(callbacks.Plugin): def changeFactoid(self, irc, msg, tokens): id = self._getUserId(irc, msg.prefix) - (key, regexp) = map(' '.join, - utils.iter.split('=~'.__eq__, tokens, maxsplit=1)) + (key, regexp) = list(map(' '.join, + utils.iter.split('=~'.__eq__, tokens, maxsplit=1))) channel = plugins.getChannel(msg.args[0]) # Check and make sure it's in the DB fact = self._getFactoid(irc, channel, key) diff --git a/plugins/Plugin/plugin.py b/plugins/Plugin/plugin.py index 6bb7ac73d..79151f783 100644 --- a/plugins/Plugin/plugin.py +++ b/plugins/Plugin/plugin.py @@ -98,7 +98,7 @@ class Plugin(callbacks.Plugin): plugin = wrap(plugin, [many('something')]) def _findCallbacks(self, irc, command): - command = map(callbacks.canonicalName, command) + command = list(map(callbacks.canonicalName, command)) plugin_list = [] for cb in irc.callbacks: if not hasattr(cb, 'getCommand'): diff --git a/plugins/Praise/plugin.py b/plugins/Praise/plugin.py index f34ac8993..ad054bb94 100644 --- a/plugins/Praise/plugin.py +++ b/plugins/Praise/plugin.py @@ -61,7 +61,7 @@ class Praise(plugins.ChannelIdDatabasePlugin): sent in the channel itself. """ if ' for ' in text: - (target, reason) = map(str.strip, text.split(' for ', 1)) + (target, reason) = list(map(str.strip, text.split(' for ', 1))) else: (target, reason) = (text, '') if ircutils.strEqual(target, irc.nick): diff --git a/plugins/Relay/plugin.py b/plugins/Relay/plugin.py index dba7e4ea4..3224ac7e6 100644 --- a/plugins/Relay/plugin.py +++ b/plugins/Relay/plugin.py @@ -171,8 +171,8 @@ class Relay(callbacks.Plugin): utils.sortBy(ircutils.toLower, voices) utils.sortBy(ircutils.toLower, halfops) utils.sortBy(ircutils.toLower, usersS) - usersS = ', '.join(filter(None, map(', '.join, - (ops,halfops,voices,usersS)))) + usersS = ', '.join(filter(None, list(map(', '.join, + (ops,halfops,voices,usersS))))) users.append(format('%s (%i): %s', ircutils.bold(network), numUsers, usersS)) users.sort() diff --git a/plugins/Seen/plugin.py b/plugins/Seen/plugin.py index 65542ae0e..f3491afa7 100644 --- a/plugins/Seen/plugin.py +++ b/plugins/Seen/plugin.py @@ -369,7 +369,7 @@ class Seen(callbacks.Plugin): msgs = [m for m in irc.state.history[i:end] if m.command == 'PRIVMSG' and ircutils.strEqual(m.args[0], channel)] if msgs: - irc.reply(format('%L', map(ircmsgs.prettyPrint, msgs))) + irc.reply(format('%L', list(map(ircmsgs.prettyPrint, msgs)))) else: irc.reply(format(_('Either %s didn\'t leave, ' 'or no messages were sent while %s was gone.'), nick, nick)) diff --git a/plugins/Unix/plugin.py b/plugins/Unix/plugin.py index 2a8fa77f4..4816f2b21 100644 --- a/plugins/Unix/plugin.py +++ b/plugins/Unix/plugin.py @@ -220,7 +220,7 @@ class Unix(callbacks.Plugin): (out, err) = inst.communicate() inst.wait() lines = out.splitlines() - lines = map(str.rstrip, lines) + lines = list(map(str.rstrip, lines)) lines = filter(None, lines) irc.replies(lines, joiner=' ') else: diff --git a/plugins/User/plugin.py b/plugins/User/plugin.py index fa4b17721..4513d001b 100644 --- a/plugins/User/plugin.py +++ b/plugins/User/plugin.py @@ -280,7 +280,7 @@ class User(callbacks.Plugin): command. """ def getHostmasks(user): - hostmasks = map(repr, user.hostmasks) + hostmasks = list(map(repr, user.hostmasks)) if hostmasks: hostmasks.sort() return format('%L', hostmasks) @@ -507,7 +507,7 @@ class User(callbacks.Plugin): prefix, expiry = self._tokens.pop(token) found = False for (id, user) in ircdb.users.items(): - if keyid in map(lambda x:x[-len(keyid):], user.gpgkeys): + if keyid in [x[-len(keyid):] for x in user.gpgkeys]: user.addAuth(msg.prefix) ircdb.users.setUser(user, flush=False) irc.reply(_('You are now authenticated as %s.') % diff --git a/plugins/Utilities/plugin.py b/plugins/Utilities/plugin.py index 3050e4afd..ee3807821 100644 --- a/plugins/Utilities/plugin.py +++ b/plugins/Utilities/plugin.py @@ -135,7 +135,7 @@ class Utilities(callbacks.Plugin): args = [token and token or '""' for token in rest] text = ' '.join(args) commands = command.split() - commands = map(callbacks.canonicalName, commands) + commands = list(map(callbacks.canonicalName, commands)) tokens = callbacks.tokenize(text) allTokens = commands + tokens self.Proxy(irc, msg, allTokens) diff --git a/setup.py b/setup.py index ed18c0afa..1cf932e5b 100644 --- a/setup.py +++ b/setup.py @@ -152,7 +152,7 @@ try: 'fix_dict', 'fix_imports', 'fix_long', - 'fix_map', 'fix_metaclass', 'fix_methodattrs', + 'fix_metaclass', 'fix_methodattrs', 'fix_numliterals', 'fix_types', 'fix_unicode', 'fix_urllib', 'fix_xrange'] diff --git a/src/callbacks.py b/src/callbacks.py index f3300f3d7..5e675071e 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -91,7 +91,7 @@ def _addressed(nick, msg, prefixChars=None, nicks=None, return payload[1:].strip() if nicks is None: nicks = get(conf.supybot.reply.whenAddressedBy.nicks) - nicks = map(ircutils.toLower, nicks) + nicks = list(map(ircutils.toLower, nicks)) else: nicks = list(nicks) # Just in case. nicks.insert(0, ircutils.toLower(nick)) @@ -738,7 +738,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy): """Returns a two-tuple of (command, plugins) that has the command (a list of strings) and the plugins for which it was a command.""" assert isinstance(args, list) - args = map(canonicalName, args) + args = list(map(canonicalName, args)) cbs = [] maxL = [] for cb in self.irc.callbacks: @@ -783,7 +783,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy): # 3. Whether an importantPlugin is one of the responses. important = defaultPlugins.importantPlugins() - important = map(canonicalName, important) + important = list(map(canonicalName, important)) importants = [] for cb in cbs: if cb.canonicalName() in important: @@ -1188,7 +1188,7 @@ class Commands(BasePlugin): return self.getCommand(command) == command def getCommand(self, args, stripOwnName=True): - assert args == map(canonicalName, args) + assert args == list(map(canonicalName, args)) first = args[0] for cb in self.cbs: if first == cb.canonicalName(): @@ -1206,7 +1206,7 @@ class Commands(BasePlugin): """Gets the given command from this plugin.""" #print '*** %s.getCommandMethod(%r)' % (self.name(), command) assert not isinstance(command, basestring) - assert command == map(canonicalName, command) + assert command == list(map(canonicalName, command)) assert self.getCommand(command) == command for cb in self.cbs: if command[0] == cb.canonicalName(): diff --git a/src/commands.py b/src/commands.py index 0c56226d7..04fe0b120 100644 --- a/src/commands.py +++ b/src/commands.py @@ -917,7 +917,7 @@ class first(context): self.default = kw.pop('default') assert not kw, 'Bad kwargs for first.__init__' self.spec = specs # for __repr__ - self.specs = map(contextify, specs) + self.specs = list(map(contextify, specs)) def __call__(self, irc, msg, args, state): errored = False diff --git a/src/ircutils.py b/src/ircutils.py index 0e5aa942d..9c293e4dc 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -162,7 +162,7 @@ def areReceivers(s, strictRfc=True, nicklen=None, chantypes='#&+!', nick = functools.partial(isNick, strictRfc=strictRfc, nicklen=nicklen) chan = functools.partial(isChannel, chantypes=chantypes, channellen=channellen) - return all(map(lambda x:nick(x) or chan(x), s.split(','))) + return all([nick(x) or chan(x) for x in s.split(',')]) _patternCache = utils.structures.CacheDict(1000) def _hostmaskPatternEqual(pattern, hostmask): diff --git a/src/registry.py b/src/registry.py index b6779c636..ef67c4264 100644 --- a/src/registry.py +++ b/src/registry.py @@ -169,7 +169,7 @@ def unescape(name): _splitRe = re.compile(r'(?