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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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