mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-29 22:29:24 +01:00
Continue accelerating the 2to3 step (remove fix_ws_comma, fix_xreadlines, and fix_zip).
This commit is contained in:
parent
ca419f6485
commit
35a62b4e77
@ -244,7 +244,7 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
|
|
||||||
def getCommandHelp(self, command, simpleSyntax=None):
|
def getCommandHelp(self, command, simpleSyntax=None):
|
||||||
method = self.getCommandMethod(command)
|
method = self.getCommandMethod(command)
|
||||||
if method.im_func.func_name == 'learn':
|
if method.im_func.__name__ == 'learn':
|
||||||
chan = None
|
chan = None
|
||||||
if dynamic.msg is not None:
|
if dynamic.msg is not None:
|
||||||
chan = dynamic.msg.args[0]
|
chan = dynamic.msg.args[0]
|
||||||
@ -352,7 +352,7 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
return []
|
return []
|
||||||
flkeys = [line[0] for line in flkeys]
|
flkeys = [line[0] for line in flkeys]
|
||||||
dl_metrics = [dameraulevenshtein(key, sourcekey) for sourcekey in flkeys]
|
dl_metrics = [dameraulevenshtein(key, sourcekey) for sourcekey in flkeys]
|
||||||
dict_metrics = dict(zip(flkeys, dl_metrics))
|
dict_metrics = dict(list(zip(flkeys, dl_metrics)))
|
||||||
if min(dl_metrics) <= 2:
|
if min(dl_metrics) <= 2:
|
||||||
return [key for key,item in dict_metrics.iteritems() if item <= 2]
|
return [key for key,item in dict_metrics.iteritems() if item <= 2]
|
||||||
if min(dl_metrics) <= 3:
|
if min(dl_metrics) <= 3:
|
||||||
|
@ -241,8 +241,8 @@ class Filter(callbacks.Plugin):
|
|||||||
irc.reply(text)
|
irc.reply(text)
|
||||||
lithp = wrap(lithp, ['text'])
|
lithp = wrap(lithp, ['text'])
|
||||||
|
|
||||||
_leettrans = utils.str.MultipleReplacer(dict(zip('oOaAeElBTiIts',
|
_leettrans = utils.str.MultipleReplacer(dict(list(zip('oOaAeElBTiIts',
|
||||||
'004433187!1+5')))
|
'004433187!1+5'))))
|
||||||
_leetres = [(re.compile(r'\b(?:(?:[yY][o0O][oO0uU])|u)\b'), 'j00'),
|
_leetres = [(re.compile(r'\b(?:(?:[yY][o0O][oO0uU])|u)\b'), 'j00'),
|
||||||
(re.compile(r'fear'), 'ph33r'),
|
(re.compile(r'fear'), 'ph33r'),
|
||||||
(re.compile(r'[aA][tT][eE]'), '8'),
|
(re.compile(r'[aA][tT][eE]'), '8'),
|
||||||
@ -662,7 +662,7 @@ class Filter(callbacks.Plugin):
|
|||||||
irc.reply(text)
|
irc.reply(text)
|
||||||
shrink = wrap(shrink, ['text'])
|
shrink = wrap(shrink, ['text'])
|
||||||
|
|
||||||
_azn_trans = utils.str.MultipleReplacer(dict(zip('rlRL', 'lrLR')))
|
_azn_trans = utils.str.MultipleReplacer(dict(list(zip('rlRL', 'lrLR'))))
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
def azn(self, irc, msg, args, text):
|
def azn(self, irc, msg, args, text):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
@ -102,7 +102,7 @@ class Format(callbacks.Plugin):
|
|||||||
if len(bad) != len(good):
|
if len(bad) != len(good):
|
||||||
irc.error(_('<chars to translate> must be the same length as '
|
irc.error(_('<chars to translate> must be the same length as '
|
||||||
'<chars to replace those with>.'), Raise=True)
|
'<chars to replace those with>.'), Raise=True)
|
||||||
irc.reply(utils.str.MultipleReplacer(dict(zip(bad, good)))(text))
|
irc.reply(utils.str.MultipleReplacer(dict(list(zip(bad, good))))(text))
|
||||||
translate = wrap(translate, ['something', 'something', 'text'])
|
translate = wrap(translate, ['something', 'something', 'text'])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
|
@ -93,7 +93,7 @@ class SqliteKarmaDB(object):
|
|||||||
def gets(self, channel, things):
|
def gets(self, channel, things):
|
||||||
db = self._getDb(channel)
|
db = self._getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
normalizedThings = dict(zip(map(lambda s: s.lower(), things), things))
|
normalizedThings = dict(list(zip(map(lambda s: s.lower(), things), things)))
|
||||||
criteria = ' OR '.join(['normalized=?'] * len(normalizedThings))
|
criteria = ' OR '.join(['normalized=?'] * len(normalizedThings))
|
||||||
sql = """SELECT name, added-subtracted FROM karma
|
sql = """SELECT name, added-subtracted FROM karma
|
||||||
WHERE %s ORDER BY added-subtracted DESC""" % criteria
|
WHERE %s ORDER BY added-subtracted DESC""" % criteria
|
||||||
|
@ -119,8 +119,8 @@ class Nickometer(callbacks.Plugin):
|
|||||||
('\\[rkx]0', 1000),
|
('\\[rkx]0', 1000),
|
||||||
('\\0[rkx]', 1000)]
|
('\\0[rkx]', 1000)]
|
||||||
|
|
||||||
letterNumberTranslator = utils.str.MultipleReplacer(dict(zip(
|
letterNumberTranslator = utils.str.MultipleReplacer(dict(list(zip(
|
||||||
'023457+8', 'ozeasttb')))
|
'023457+8', 'ozeasttb'))))
|
||||||
for special in specialCost:
|
for special in specialCost:
|
||||||
tempNick = nick
|
tempNick = nick
|
||||||
if special[0][0] != '\\':
|
if special[0][0] != '\\':
|
||||||
|
@ -93,7 +93,7 @@ def fetch_sandbox(f):
|
|||||||
try:
|
try:
|
||||||
replies = commands.process(process, self, irc, *args,
|
replies = commands.process(process, self, irc, *args,
|
||||||
timeout=5, heap_size=1024*1024,
|
timeout=5, heap_size=1024*1024,
|
||||||
pn=self.name(), cn=f.func_name)
|
pn=self.name(), cn=f.__name__)
|
||||||
except commands.ProcessTimeoutError:
|
except commands.ProcessTimeoutError:
|
||||||
raise utils.web.Error(_('Page is too big.'))
|
raise utils.web.Error(_('Page is too big.'))
|
||||||
else:
|
else:
|
||||||
|
3
setup.py
3
setup.py
@ -156,8 +156,7 @@ try:
|
|||||||
'fix_map', 'fix_metaclass', 'fix_methodattrs',
|
'fix_map', 'fix_metaclass', 'fix_methodattrs',
|
||||||
'fix_numliterals',
|
'fix_numliterals',
|
||||||
'fix_types',
|
'fix_types',
|
||||||
'fix_unicode', 'fix_urllib', 'fix_ws_comma', 'fix_xrange',
|
'fix_unicode', 'fix_urllib', 'fix_xrange']
|
||||||
'fix_xreadlines', 'fix_zip']
|
|
||||||
fixers = list(map(lambda x:'lib2to3.fixes.'+x, fixer_names))
|
fixers = list(map(lambda x:'lib2to3.fixes.'+x, fixer_names))
|
||||||
fixers += get_fixers_from_package('2to3')
|
fixers += get_fixers_from_package('2to3')
|
||||||
r = DistutilsRefactoringTool(fixers, options=options)
|
r = DistutilsRefactoringTool(fixers, options=options)
|
||||||
|
@ -1170,7 +1170,7 @@ class Commands(BasePlugin):
|
|||||||
if hasattr(self, name):
|
if hasattr(self, name):
|
||||||
method = getattr(self, name)
|
method = getattr(self, name)
|
||||||
if inspect.ismethod(method):
|
if inspect.ismethod(method):
|
||||||
code = method.im_func.func_code
|
code = method.im_func.__code__
|
||||||
return inspect.getargs(code)[0] == self.commandArgs
|
return inspect.getargs(code)[0] == self.commandArgs
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@ -1217,7 +1217,7 @@ class Commands(BasePlugin):
|
|||||||
else:
|
else:
|
||||||
method = getattr(self, command[0])
|
method = getattr(self, command[0])
|
||||||
if inspect.ismethod(method):
|
if inspect.ismethod(method):
|
||||||
code = method.im_func.func_code
|
code = method.im_func.__code__
|
||||||
if inspect.getargs(code)[0] == self.commandArgs:
|
if inspect.getargs(code)[0] == self.commandArgs:
|
||||||
return method
|
return method
|
||||||
else:
|
else:
|
||||||
|
@ -67,7 +67,7 @@ def thread(f):
|
|||||||
t.start()
|
t.start()
|
||||||
else:
|
else:
|
||||||
f(self, irc, msg, args, *L, **kwargs)
|
f(self, irc, msg, args, *L, **kwargs)
|
||||||
return utils.python.changeFunctionName(newf, f.func_name, f.__doc__)
|
return utils.python.changeFunctionName(newf, f.__name__, f.__doc__)
|
||||||
|
|
||||||
class ProcessTimeoutError(Exception):
|
class ProcessTimeoutError(Exception):
|
||||||
"""Gets raised when a process is killed due to timeout."""
|
"""Gets raised when a process is killed due to timeout."""
|
||||||
@ -219,7 +219,7 @@ def urlSnarfer(f):
|
|||||||
L = list(L)
|
L = list(L)
|
||||||
t = UrlSnarfThread(target=doSnarf, url=url)
|
t = UrlSnarfThread(target=doSnarf, url=url)
|
||||||
t.start()
|
t.start()
|
||||||
newf = utils.python.changeFunctionName(newf, f.func_name, f.__doc__)
|
newf = utils.python.changeFunctionName(newf, f.__name__, f.__doc__)
|
||||||
return newf
|
return newf
|
||||||
|
|
||||||
|
|
||||||
@ -1068,7 +1068,7 @@ class Spec(object):
|
|||||||
return state
|
return state
|
||||||
|
|
||||||
def _wrap(f, specList=[], name=None, checkDoc=True, **kw):
|
def _wrap(f, specList=[], name=None, checkDoc=True, **kw):
|
||||||
name = name or f.func_name
|
name = name or f.__name__
|
||||||
assert (not checkDoc) or (hasattr(f, '__doc__') and f.__doc__), \
|
assert (not checkDoc) or (hasattr(f, '__doc__') and f.__doc__), \
|
||||||
'Command %r has no docstring.' % name
|
'Command %r has no docstring.' % name
|
||||||
f = internationalizeDocstring(f)
|
f = internationalizeDocstring(f)
|
||||||
@ -1084,7 +1084,7 @@ def _wrap(f, specList=[], name=None, checkDoc=True, **kw):
|
|||||||
except TypeError:
|
except TypeError:
|
||||||
self.log.error('Spec: %s', specList)
|
self.log.error('Spec: %s', specList)
|
||||||
self.log.error('Received args: %s', args)
|
self.log.error('Received args: %s', args)
|
||||||
code = f.func_code
|
code = f.__code__
|
||||||
funcArgs = inspect.getargs(code)[0][len(self.commandArgs):]
|
funcArgs = inspect.getargs(code)[0][len(self.commandArgs):]
|
||||||
self.log.error('Extra args: %s', funcArgs)
|
self.log.error('Extra args: %s', funcArgs)
|
||||||
self.log.debug('Make sure you did not wrap a wrapped '
|
self.log.debug('Make sure you did not wrap a wrapped '
|
||||||
|
@ -435,9 +435,9 @@ class IrcState(IrcCommandDispatcher):
|
|||||||
assert left[0] == '(', 'Odd PREFIX in 005: %s' % s
|
assert left[0] == '(', 'Odd PREFIX in 005: %s' % s
|
||||||
left = left[1:]
|
left = left[1:]
|
||||||
assert len(left) == len(right), 'Odd PREFIX in 005: %s' % s
|
assert len(left) == len(right), 'Odd PREFIX in 005: %s' % s
|
||||||
return dict(zip(left, right))
|
return dict(list(zip(left, right)))
|
||||||
else:
|
else:
|
||||||
return dict(zip('ovh', s))
|
return dict(list(zip('ovh', s)))
|
||||||
_005converters['prefix'] = _prefixParser
|
_005converters['prefix'] = _prefixParser
|
||||||
del _prefixParser
|
del _prefixParser
|
||||||
def _maxlistParser(s):
|
def _maxlistParser(s):
|
||||||
@ -448,7 +448,7 @@ class IrcState(IrcCommandDispatcher):
|
|||||||
(mode, limit) = pair.split(':', 1)
|
(mode, limit) = pair.split(':', 1)
|
||||||
modes += mode
|
modes += mode
|
||||||
limits += (int(limit),) * len(mode)
|
limits += (int(limit),) * len(mode)
|
||||||
return dict(zip(modes, limits))
|
return dict(list(zip(modes, limits)))
|
||||||
_005converters['maxlist'] = _maxlistParser
|
_005converters['maxlist'] = _maxlistParser
|
||||||
del _maxlistParser
|
del _maxlistParser
|
||||||
def _maxbansParser(s):
|
def _maxbansParser(s):
|
||||||
@ -461,7 +461,7 @@ class IrcState(IrcCommandDispatcher):
|
|||||||
(mode, limit) = pair.split(':', 1)
|
(mode, limit) = pair.split(':', 1)
|
||||||
modes += mode
|
modes += mode
|
||||||
limits += (int(limit),) * len(mode)
|
limits += (int(limit),) * len(mode)
|
||||||
d = dict(zip(modes, limits))
|
d = dict(list(zip(modes, limits)))
|
||||||
assert 'b' in d
|
assert 'b' in d
|
||||||
return d['b']
|
return d['b']
|
||||||
else:
|
else:
|
||||||
|
@ -97,9 +97,9 @@ def joinHostmask(nick, ident, host):
|
|||||||
assert nick and ident and host
|
assert nick and ident and host
|
||||||
return minisix.intern('%s!%s@%s' % (nick, ident, host))
|
return minisix.intern('%s!%s@%s' % (nick, ident, host))
|
||||||
|
|
||||||
_rfc1459trans = utils.str.MultipleReplacer(dict(zip(
|
_rfc1459trans = utils.str.MultipleReplacer(dict(list(zip(
|
||||||
string.ascii_uppercase + r'\[]~',
|
string.ascii_uppercase + r'\[]~',
|
||||||
string.ascii_lowercase + r'|{}^')))
|
string.ascii_lowercase + r'|{}^'))))
|
||||||
def toLower(s, casemapping=None):
|
def toLower(s, casemapping=None):
|
||||||
"""s => s
|
"""s => s
|
||||||
Returns the string s lowered according to IRC case rules."""
|
Returns the string s lowered according to IRC case rules."""
|
||||||
|
@ -346,7 +346,7 @@ def firewall(f, errorHandler=None):
|
|||||||
logging_function = self.log.exception
|
logging_function = self.log.exception
|
||||||
else:
|
else:
|
||||||
logging_function = exception
|
logging_function = exception
|
||||||
logging_function('%s in %s.%s:', s, self.__class__.__name__, f.func_name)
|
logging_function('%s in %s.%s:', s, self.__class__.__name__, f.__name__)
|
||||||
def m(self, *args, **kwargs):
|
def m(self, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return f(self, *args, **kwargs)
|
return f(self, *args, **kwargs)
|
||||||
@ -359,7 +359,7 @@ def firewall(f, errorHandler=None):
|
|||||||
return errorHandler(self, *args, **kwargs)
|
return errorHandler(self, *args, **kwargs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logException(self, 'Uncaught exception in errorHandler')
|
logException(self, 'Uncaught exception in errorHandler')
|
||||||
m = utils.python.changeFunctionName(m, f.func_name, f.__doc__)
|
m = utils.python.changeFunctionName(m, f.__name__, f.__doc__)
|
||||||
return m
|
return m
|
||||||
|
|
||||||
class MetaFirewall(type):
|
class MetaFirewall(type):
|
||||||
|
@ -58,8 +58,8 @@ def universalImport(*names):
|
|||||||
def changeFunctionName(f, name, doc=None):
|
def changeFunctionName(f, name, doc=None):
|
||||||
if doc is None:
|
if doc is None:
|
||||||
doc = f.__doc__
|
doc = f.__doc__
|
||||||
newf = types.FunctionType(f.func_code, f.func_globals, name,
|
newf = types.FunctionType(f.__code__, f.__globals__, name,
|
||||||
f.func_defaults, f.func_closure)
|
f.__defaults__, f.__closure__)
|
||||||
newf.__doc__ = doc
|
newf.__doc__ = doc
|
||||||
return newf
|
return newf
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ class Synchronized(type):
|
|||||||
f(self, *args, **kwargs)
|
f(self, *args, **kwargs)
|
||||||
finally:
|
finally:
|
||||||
lock.release()
|
lock.release()
|
||||||
return changeFunctionName(g, f.func_name, f.__doc__)
|
return changeFunctionName(g, f.__name__, f.__doc__)
|
||||||
for attr in sync:
|
for attr in sync:
|
||||||
if attr in dict:
|
if attr in dict:
|
||||||
dict[attr] = synchronized(dict[attr])
|
dict[attr] = synchronized(dict[attr])
|
||||||
|
@ -114,8 +114,8 @@ class MultipleRemover:
|
|||||||
def __call__(self, s):
|
def __call__(self, s):
|
||||||
return self._matcher.sub(lambda m: '', s)
|
return self._matcher.sub(lambda m: '', s)
|
||||||
|
|
||||||
_soundextrans = MultipleReplacer(dict(zip(string.ascii_uppercase,
|
_soundextrans = MultipleReplacer(dict(list(zip(string.ascii_uppercase,
|
||||||
'01230120022455012623010202')))
|
'01230120022455012623010202'))))
|
||||||
def soundex(s, length=4):
|
def soundex(s, length=4):
|
||||||
"""Returns the soundex hash of a given string.
|
"""Returns the soundex hash of a given string.
|
||||||
|
|
||||||
|
@ -479,7 +479,7 @@ class IterTest(SupyTestCase):
|
|||||||
self.assertEqual(lflatten(range(10)), list(range(10)))
|
self.assertEqual(lflatten(range(10)), list(range(10)))
|
||||||
twoRanges = list(range(10))*2
|
twoRanges = list(range(10))*2
|
||||||
twoRanges.sort()
|
twoRanges.sort()
|
||||||
self.assertEqual(lflatten(zip(range(10), range(10))), twoRanges)
|
self.assertEqual(lflatten(list(zip(range(10), range(10)))), twoRanges)
|
||||||
self.assertEqual(lflatten([1, [2, 3], 4]), [1, 2, 3, 4])
|
self.assertEqual(lflatten([1, [2, 3], 4]), [1, 2, 3, 4])
|
||||||
self.assertEqual(lflatten([[[[[[[[[[]]]]]]]]]]), [])
|
self.assertEqual(lflatten([[[[[[[[[[]]]]]]]]]]), [])
|
||||||
self.assertEqual(lflatten([1, [2, [3, 4], 5], 6]), [1, 2, 3, 4, 5, 6])
|
self.assertEqual(lflatten([1, [2, [3, 4], 5], 6]), [1, 2, 3, 4, 5, 6])
|
||||||
|
Loading…
Reference in New Issue
Block a user