diff --git a/plugins/Channel/plugin.py b/plugins/Channel/plugin.py index fd591ad28..bdbc5e191 100644 --- a/plugins/Channel/plugin.py +++ b/plugins/Channel/plugin.py @@ -808,7 +808,7 @@ class Channel(callbacks.Plugin): 'called %s.'), plugin.name(), command) elif command: # findCallbackForCommand - if filter(None, irc.findCallbacksForArgs([command])): + if list(filter(None, irc.findCallbacksForArgs([command]))): s = '-%s' % command else: failMsg = format(_('No plugin or command named %s could be ' @@ -847,7 +847,7 @@ class Channel(callbacks.Plugin): 'called %s.'), plugin.name(), command) elif command: # findCallbackForCommand - if filter(None, irc.findCallbacksForArgs([command])): + if list(filter(None, irc.findCallbacksForArgs([command]))): s = '-%s' % command else: failMsg = format(_('No plugin or command named %s could be ' diff --git a/plugins/Dict/local/dictclient.py b/plugins/Dict/local/dictclient.py index 64cef4097..fa11a7008 100644 --- a/plugins/Dict/local/dictclient.py +++ b/plugins/Dict/local/dictclient.py @@ -149,7 +149,7 @@ class Connection: if not hasattr(self, 'dbobjs'): self.dbobjs = {} - if self.dbobjs.has_key(dbname): + if dbname in self.dbobjs: return self.dbobjs[dbname] # We use self.dbdescs explicitly since we don't want to diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index 2fe2bbdcd..e648e8f4d 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -162,7 +162,7 @@ class Google(callbacks.PluginRegexp): data = self.search(text, msg.args[0], {'smallsearch': True}) if data['responseData']['results']: url = data['responseData']['results'][0]['unescapedUrl'] - if opts.has_key('snippet'): + if 'snippet' in opts: snippet = data['responseData']['results'][0]['content'] snippet = " | " + utils.web.htmlToText(snippet, tagReplace='') else: diff --git a/plugins/RSS/plugin.py b/plugins/RSS/plugin.py index 6bf887a9a..e2929e531 100644 --- a/plugins/RSS/plugin.py +++ b/plugins/RSS/plugin.py @@ -181,7 +181,8 @@ class RSS(callbacks.Plugin): #oldresults = self.cachedFeeds[url] #oldheadlines = self.getHeadlines(oldresults) oldheadlines = self.cachedHeadlines[url] - oldheadlines = filter(lambda x: t - x[3] < self.registryValue('announce.cachePeriod'), oldheadlines) + oldheadlines = list(filter(lambda x: t - x[3] < + self.registryValue('announce.cachePeriod'), oldheadlines)) except KeyError: oldheadlines = [] newresults = self.getFeed(url) @@ -198,7 +199,7 @@ class RSS(callbacks.Plugin): for (i, headline) in enumerate(newheadlines): if normalize(headline) in oldheadlinesset: newheadlines[i] = None - newheadlines = filter(None, newheadlines) # Removes Nones. + newheadlines = list(filter(None, newheadlines)) # Removes Nones. number_of_headlines = len(oldheadlines) oldheadlines.extend(newheadlines) self.cachedHeadlines[url] = oldheadlines @@ -228,6 +229,7 @@ class RSS(callbacks.Plugin): channelnewheadlines = filter(filter_whitelist, channelnewheadlines) if len(blacklist) != 0: channelnewheadlines = filter(filter_blacklist, channelnewheadlines) + channelnewheadlines = list(channelnewheadlines) if len(channelnewheadlines) == 0: return bold = self.registryValue('bold', channel) diff --git a/plugins/Topic/plugin.py b/plugins/Topic/plugin.py index d83593d92..dc1065868 100644 --- a/plugins/Topic/plugin.py +++ b/plugins/Topic/plugin.py @@ -105,7 +105,7 @@ addConverter('topicNumber', getTopicNumber) addConverter('canChangeTopic', canChangeTopic) def splitTopic(topic, separator): - return filter(None, topic.split(separator)) + return list(filter(None, topic.split(separator))) datadir = conf.supybot.directories.data() filename = conf.supybot.directories.data.dirize('Topic.pickle') diff --git a/plugins/Utilities/plugin.py b/plugins/Utilities/plugin.py index 8d0452603..50f49cf4e 100644 --- a/plugins/Utilities/plugin.py +++ b/plugins/Utilities/plugin.py @@ -75,7 +75,7 @@ class Utilities(callbacks.Plugin): nested commands to run, but only the output of the last one to be returned. """ - args = filter(None, args) + args = list(filter(None, args)) if args: irc.reply(args[-1]) else: diff --git a/setup.py b/setup.py index 36648d3fb..070c43c0d 100644 --- a/setup.py +++ b/setup.py @@ -148,11 +148,10 @@ try: def log_debug(self, msg, *args): log.debug(msg, *args) - fixer_names = ['fix_apply', 'fix_basestring', 'fix_buffer', - 'fix_callable', 'fix_dict', 'fix_except', 'fix_exec', - 'fix_execfile', 'fix_exitfunc', 'fix_filter', - 'fix_funcattrs', 'fix_future', 'fix_getcwdu', - 'fix_has_key', 'fix_idioms', 'fix_imports', 'fix_imports2', + fixer_names = ['fix_basestring', + 'fix_dict', 'fix_except', + 'fix_funcattrs', + 'fix_idioms', 'fix_imports', 'fix_imports2', 'fix_input', 'fix_intern', 'fix_isinstance', 'fix_itertools', 'fix_itertools_imports', 'fix_long', 'fix_map', 'fix_metaclass', 'fix_methodattrs', 'fix_ne', diff --git a/src/drivers/Socket.py b/src/drivers/Socket.py index 7045df269..b49c52e74 100644 --- a/src/drivers/Socket.py +++ b/src/drivers/Socket.py @@ -82,7 +82,7 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin): self.writeCheckTime = None self.nextReconnectTime = None self.resetDelay() - if self.networkGroup.get('ssl').value and not globals().has_key('ssl'): + if self.networkGroup.get('ssl').value and 'ssl' not in globals(): drivers.log.error('The Socket driver can not connect to SSL ' 'servers for your Python version. Try the ' 'Twisted driver instead, or install a Python' @@ -304,7 +304,7 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin): self.conn.settimeout(max(10, conf.supybot.drivers.poll()*10)) try: if getattr(conf.supybot.networks, self.irc.network).ssl(): - assert globals().has_key('ssl') + assert 'ssl' in globals() certfile = getattr(conf.supybot.networks, self.irc.network) \ .certfile() if not certfile: diff --git a/src/i18n.py b/src/i18n.py index f1aa9d5a4..28d7c5860 100644 --- a/src/i18n.py +++ b/src/i18n.py @@ -131,7 +131,7 @@ def reloadLocales(): i18nSupybot = None def PluginInternationalization(name='supybot'): # This is a proxy that prevents having several objects for the same plugin - if i18nClasses.has_key(name): + if name in i18nClasses: return i18nClasses[name] else: return _PluginInternationalization(name) @@ -276,8 +276,10 @@ class _PluginInternationalization: load its functions.""" if self.name != 'supybot': return + path = self._getL10nCodePath() try: - execfile(self._getL10nCodePath()) + with open(path) as fd: + exec(compile(fd.read(), path, 'exec')) except IOError: # File doesn't exist pass @@ -302,7 +304,7 @@ class _PluginInternationalization: if self.name != 'supybot': return if hasattr(self, '_l10nFunctions') and \ - self._l10nFunctions.has_key(name): + name in self._l10nFunctions: return self._l10nFunctions[name] def internationalizeFunction(self, name): @@ -351,7 +353,7 @@ def internationalizeDocstring(obj): Only useful for commands (commands' docstring is displayed on IRC)""" if obj.__doc__ == None: return obj - if sys.modules[obj.__module__].__dict__.has_key('_'): + if '_' in sys.modules[obj.__module__].__dict__: internationalizedCommands.update({hash(obj): obj}) try: obj.__doc__=sys.modules[obj.__module__]._.__call__(obj.__doc__) diff --git a/src/ircdb.py b/src/ircdb.py index 73dfb0288..1cf3fe4b7 100644 --- a/src/ircdb.py +++ b/src/ircdb.py @@ -334,7 +334,7 @@ class IrcUser(object): knownHostmasks.add(mask) return True return False - uniqued = filter(uniqueHostmask, reversed(self.auth)) + uniqued = list(filter(uniqueHostmask, reversed(self.auth))) self.auth = list(reversed(uniqued)) else: raise ValueError, 'secure flag set, unmatched hostmask' diff --git a/src/plugin.py b/src/plugin.py index 324a38792..5d63800c2 100644 --- a/src/plugin.py +++ b/src/plugin.py @@ -54,8 +54,8 @@ def loadPluginModule(name, ignoreDeprecation=False): log.warning('Invalid plugin directory: %s; removing.', dir) conf.supybot.directories.plugins().remove(dir) if name not in files: - matched_names = filter(lambda x: re.search(r'(?i)^%s$' % (name,), x), - files) + search = lambda x: re.search(r'(?i)^%s$' % (name,), x) + matched_names = list(filter(search, files)) if len(matched_names) == 1: name = matched_names[0] else: diff --git a/src/utils/str.py b/src/utils/str.py index 0e9c18947..8b8aacfef 100644 --- a/src/utils/str.py +++ b/src/utils/str.py @@ -218,7 +218,7 @@ def perlReToReplacer(s): g = False if 'g' in flags: g = True - flags = filter('g'.__ne__, flags) + flags = list(filter('g'.__ne__, flags)) if isinstance(flags, list): flags = ''.join(flags) r = perlReToPythonRe(sep.join(('', regexp, flags)))