Start accelerating the 2to3 step (remove fix_apply, fix_buffer, fix_callable, fix_exec, fix_execfile, fix_exitfunc, fix_filter, fix_funcattrs, fix_future, fix_getcwdu, and fix_has_key).

This commit is contained in:
Valentin Lorentz 2014-01-20 14:49:47 +01:00
parent a277ace2bf
commit 4652c9ce51
12 changed files with 26 additions and 23 deletions

View File

@ -808,7 +808,7 @@ class Channel(callbacks.Plugin):
'called %s.'), plugin.name(), command) 'called %s.'), plugin.name(), command)
elif command: elif command:
# findCallbackForCommand # findCallbackForCommand
if filter(None, irc.findCallbacksForArgs([command])): if list(filter(None, irc.findCallbacksForArgs([command]))):
s = '-%s' % command s = '-%s' % command
else: else:
failMsg = format(_('No plugin or command named %s could be ' failMsg = format(_('No plugin or command named %s could be '
@ -847,7 +847,7 @@ class Channel(callbacks.Plugin):
'called %s.'), plugin.name(), command) 'called %s.'), plugin.name(), command)
elif command: elif command:
# findCallbackForCommand # findCallbackForCommand
if filter(None, irc.findCallbacksForArgs([command])): if list(filter(None, irc.findCallbacksForArgs([command]))):
s = '-%s' % command s = '-%s' % command
else: else:
failMsg = format(_('No plugin or command named %s could be ' failMsg = format(_('No plugin or command named %s could be '

View File

@ -149,7 +149,7 @@ class Connection:
if not hasattr(self, 'dbobjs'): if not hasattr(self, 'dbobjs'):
self.dbobjs = {} self.dbobjs = {}
if self.dbobjs.has_key(dbname): if dbname in self.dbobjs:
return self.dbobjs[dbname] return self.dbobjs[dbname]
# We use self.dbdescs explicitly since we don't want to # We use self.dbdescs explicitly since we don't want to

View File

@ -162,7 +162,7 @@ class Google(callbacks.PluginRegexp):
data = self.search(text, msg.args[0], {'smallsearch': True}) data = self.search(text, msg.args[0], {'smallsearch': True})
if data['responseData']['results']: if data['responseData']['results']:
url = data['responseData']['results'][0]['unescapedUrl'] url = data['responseData']['results'][0]['unescapedUrl']
if opts.has_key('snippet'): if 'snippet' in opts:
snippet = data['responseData']['results'][0]['content'] snippet = data['responseData']['results'][0]['content']
snippet = " | " + utils.web.htmlToText(snippet, tagReplace='') snippet = " | " + utils.web.htmlToText(snippet, tagReplace='')
else: else:

View File

@ -181,7 +181,8 @@ class RSS(callbacks.Plugin):
#oldresults = self.cachedFeeds[url] #oldresults = self.cachedFeeds[url]
#oldheadlines = self.getHeadlines(oldresults) #oldheadlines = self.getHeadlines(oldresults)
oldheadlines = self.cachedHeadlines[url] 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: except KeyError:
oldheadlines = [] oldheadlines = []
newresults = self.getFeed(url) newresults = self.getFeed(url)
@ -198,7 +199,7 @@ class RSS(callbacks.Plugin):
for (i, headline) in enumerate(newheadlines): for (i, headline) in enumerate(newheadlines):
if normalize(headline) in oldheadlinesset: if normalize(headline) in oldheadlinesset:
newheadlines[i] = None newheadlines[i] = None
newheadlines = filter(None, newheadlines) # Removes Nones. newheadlines = list(filter(None, newheadlines)) # Removes Nones.
number_of_headlines = len(oldheadlines) number_of_headlines = len(oldheadlines)
oldheadlines.extend(newheadlines) oldheadlines.extend(newheadlines)
self.cachedHeadlines[url] = oldheadlines self.cachedHeadlines[url] = oldheadlines
@ -228,6 +229,7 @@ class RSS(callbacks.Plugin):
channelnewheadlines = filter(filter_whitelist, channelnewheadlines) channelnewheadlines = filter(filter_whitelist, channelnewheadlines)
if len(blacklist) != 0: if len(blacklist) != 0:
channelnewheadlines = filter(filter_blacklist, channelnewheadlines) channelnewheadlines = filter(filter_blacklist, channelnewheadlines)
channelnewheadlines = list(channelnewheadlines)
if len(channelnewheadlines) == 0: if len(channelnewheadlines) == 0:
return return
bold = self.registryValue('bold', channel) bold = self.registryValue('bold', channel)

View File

@ -105,7 +105,7 @@ addConverter('topicNumber', getTopicNumber)
addConverter('canChangeTopic', canChangeTopic) addConverter('canChangeTopic', canChangeTopic)
def splitTopic(topic, separator): def splitTopic(topic, separator):
return filter(None, topic.split(separator)) return list(filter(None, topic.split(separator)))
datadir = conf.supybot.directories.data() datadir = conf.supybot.directories.data()
filename = conf.supybot.directories.data.dirize('Topic.pickle') filename = conf.supybot.directories.data.dirize('Topic.pickle')

View File

@ -75,7 +75,7 @@ class Utilities(callbacks.Plugin):
nested commands to run, but only the output of the last one to be nested commands to run, but only the output of the last one to be
returned. returned.
""" """
args = filter(None, args) args = list(filter(None, args))
if args: if args:
irc.reply(args[-1]) irc.reply(args[-1])
else: else:

View File

@ -148,11 +148,10 @@ try:
def log_debug(self, msg, *args): def log_debug(self, msg, *args):
log.debug(msg, *args) log.debug(msg, *args)
fixer_names = ['fix_apply', 'fix_basestring', 'fix_buffer', fixer_names = ['fix_basestring',
'fix_callable', 'fix_dict', 'fix_except', 'fix_exec', 'fix_dict', 'fix_except',
'fix_execfile', 'fix_exitfunc', 'fix_filter', 'fix_funcattrs',
'fix_funcattrs', 'fix_future', 'fix_getcwdu', 'fix_idioms', 'fix_imports', 'fix_imports2',
'fix_has_key', 'fix_idioms', 'fix_imports', 'fix_imports2',
'fix_input', 'fix_intern', 'fix_isinstance', 'fix_input', 'fix_intern', 'fix_isinstance',
'fix_itertools', 'fix_itertools_imports', 'fix_long', 'fix_itertools', 'fix_itertools_imports', 'fix_long',
'fix_map', 'fix_metaclass', 'fix_methodattrs', 'fix_ne', 'fix_map', 'fix_metaclass', 'fix_methodattrs', 'fix_ne',

View File

@ -82,7 +82,7 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
self.writeCheckTime = None self.writeCheckTime = None
self.nextReconnectTime = None self.nextReconnectTime = None
self.resetDelay() 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 ' drivers.log.error('The Socket driver can not connect to SSL '
'servers for your Python version. Try the ' 'servers for your Python version. Try the '
'Twisted driver instead, or install a Python' '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)) self.conn.settimeout(max(10, conf.supybot.drivers.poll()*10))
try: try:
if getattr(conf.supybot.networks, self.irc.network).ssl(): 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 = getattr(conf.supybot.networks, self.irc.network) \
.certfile() .certfile()
if not certfile: if not certfile:

View File

@ -131,7 +131,7 @@ def reloadLocales():
i18nSupybot = None i18nSupybot = None
def PluginInternationalization(name='supybot'): def PluginInternationalization(name='supybot'):
# This is a proxy that prevents having several objects for the same plugin # 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] return i18nClasses[name]
else: else:
return _PluginInternationalization(name) return _PluginInternationalization(name)
@ -276,8 +276,10 @@ class _PluginInternationalization:
load its functions.""" load its functions."""
if self.name != 'supybot': if self.name != 'supybot':
return return
path = self._getL10nCodePath()
try: try:
execfile(self._getL10nCodePath()) with open(path) as fd:
exec(compile(fd.read(), path, 'exec'))
except IOError: # File doesn't exist except IOError: # File doesn't exist
pass pass
@ -302,7 +304,7 @@ class _PluginInternationalization:
if self.name != 'supybot': if self.name != 'supybot':
return return
if hasattr(self, '_l10nFunctions') and \ if hasattr(self, '_l10nFunctions') and \
self._l10nFunctions.has_key(name): name in self._l10nFunctions:
return self._l10nFunctions[name] return self._l10nFunctions[name]
def internationalizeFunction(self, name): def internationalizeFunction(self, name):
@ -351,7 +353,7 @@ def internationalizeDocstring(obj):
Only useful for commands (commands' docstring is displayed on IRC)""" Only useful for commands (commands' docstring is displayed on IRC)"""
if obj.__doc__ == None: if obj.__doc__ == None:
return obj return obj
if sys.modules[obj.__module__].__dict__.has_key('_'): if '_' in sys.modules[obj.__module__].__dict__:
internationalizedCommands.update({hash(obj): obj}) internationalizedCommands.update({hash(obj): obj})
try: try:
obj.__doc__=sys.modules[obj.__module__]._.__call__(obj.__doc__) obj.__doc__=sys.modules[obj.__module__]._.__call__(obj.__doc__)

View File

@ -334,7 +334,7 @@ class IrcUser(object):
knownHostmasks.add(mask) knownHostmasks.add(mask)
return True return True
return False return False
uniqued = filter(uniqueHostmask, reversed(self.auth)) uniqued = list(filter(uniqueHostmask, reversed(self.auth)))
self.auth = list(reversed(uniqued)) self.auth = list(reversed(uniqued))
else: else:
raise ValueError, 'secure flag set, unmatched hostmask' raise ValueError, 'secure flag set, unmatched hostmask'

View File

@ -54,8 +54,8 @@ def loadPluginModule(name, ignoreDeprecation=False):
log.warning('Invalid plugin directory: %s; removing.', dir) log.warning('Invalid plugin directory: %s; removing.', dir)
conf.supybot.directories.plugins().remove(dir) conf.supybot.directories.plugins().remove(dir)
if name not in files: if name not in files:
matched_names = filter(lambda x: re.search(r'(?i)^%s$' % (name,), x), search = lambda x: re.search(r'(?i)^%s$' % (name,), x)
files) matched_names = list(filter(search, files))
if len(matched_names) == 1: if len(matched_names) == 1:
name = matched_names[0] name = matched_names[0]
else: else:

View File

@ -218,7 +218,7 @@ def perlReToReplacer(s):
g = False g = False
if 'g' in flags: if 'g' in flags:
g = True g = True
flags = filter('g'.__ne__, flags) flags = list(filter('g'.__ne__, flags))
if isinstance(flags, list): if isinstance(flags, list):
flags = ''.join(flags) flags = ''.join(flags)
r = perlReToPythonRe(sep.join(('', regexp, flags))) r = perlReToPythonRe(sep.join(('', regexp, flags)))