mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-04-26 09:47:52 +02:00
Continue accelerating the 2to3 step (remove fix_reduce, fix_renames, fix_repr, fix_set_literal, fix_standarderror, fix_sys_exc, fix_throw, and fix_tuple_params).
This commit is contained in:
parent
bb7db3ab21
commit
ca419f6485
@ -151,7 +151,7 @@ class Admin(callbacks.Plugin):
|
|||||||
networkGroup.channels().add(channel)
|
networkGroup.channels().add(channel)
|
||||||
if key:
|
if key:
|
||||||
networkGroup.channels.key.get(channel).setValue(key)
|
networkGroup.channels.key.get(channel).setValue(key)
|
||||||
maxchannels = irc.state.supported.get('maxchannels', sys.maxint)
|
maxchannels = irc.state.supported.get('maxchannels', sys.maxsize)
|
||||||
if len(irc.state.channels) + 1 > maxchannels:
|
if len(irc.state.channels) + 1 > maxchannels:
|
||||||
irc.error(_('I\'m already too close to maximum number of '
|
irc.error(_('I\'m already too close to maximum number of '
|
||||||
'channels for this network.'), Raise=True)
|
'channels for this network.'), Raise=True)
|
||||||
|
@ -279,7 +279,7 @@ class Channel(callbacks.Plugin):
|
|||||||
irc.error(_('I cowardly refuse to kick myself.'), Raise=True)
|
irc.error(_('I cowardly refuse to kick myself.'), Raise=True)
|
||||||
if not reason:
|
if not reason:
|
||||||
reason = msg.nick
|
reason = msg.nick
|
||||||
kicklen = irc.state.supported.get('kicklen', sys.maxint)
|
kicklen = irc.state.supported.get('kicklen', sys.maxsize)
|
||||||
if len(reason) > kicklen:
|
if len(reason) > kicklen:
|
||||||
irc.error(_('The reason you gave is longer than the allowed '
|
irc.error(_('The reason you gave is longer than the allowed '
|
||||||
'length for a KICK reason on this server.'),
|
'length for a KICK reason on this server.'),
|
||||||
|
@ -163,7 +163,7 @@ class Nickometer(callbacks.Plugin):
|
|||||||
# Punish k3wlt0k
|
# Punish k3wlt0k
|
||||||
k3wlt0k_weights = (5, 5, 2, 5, 2, 3, 1, 2, 2, 2)
|
k3wlt0k_weights = (5, 5, 2, 5, 2, 3, 1, 2, 2, 2)
|
||||||
for i in range(len(k3wlt0k_weights)):
|
for i in range(len(k3wlt0k_weights)):
|
||||||
hits=re.findall(`i`, nick)
|
hits=re.findall(repr(i), nick)
|
||||||
if (hits and len(hits)>0):
|
if (hits and len(hits)>0):
|
||||||
score += self.punish(k3wlt0k_weights[i] * len(hits) * 30,
|
score += self.punish(k3wlt0k_weights[i] * len(hits) * 30,
|
||||||
'%s occurrences of %s ' % (len(hits), i))
|
'%s occurrences of %s ' % (len(hits), i))
|
||||||
@ -225,7 +225,7 @@ class Nickometer(callbacks.Plugin):
|
|||||||
(1 - 1 / (1 + score / 5.0)) // 2
|
(1 - 1 / (1 + score / 5.0)) // 2
|
||||||
|
|
||||||
# if it's above 99.9%, show as many digits as is interesting
|
# if it's above 99.9%, show as many digits as is interesting
|
||||||
score_string=re.sub('(99\\.9*\\d|\\.\\d).*','\\1',`percentage`)
|
score_string=re.sub('(99\\.9*\\d|\\.\\d).*','\\1',repr(percentage))
|
||||||
|
|
||||||
irc.reply(_('The "lame nick-o-meter" reading for "%s" is %s%%.') %
|
irc.reply(_('The "lame nick-o-meter" reading for "%s" is %s%%.') %
|
||||||
(originalNick, score_string))
|
(originalNick, score_string))
|
||||||
|
@ -415,7 +415,7 @@ class User(callbacks.Plugin):
|
|||||||
|
|
||||||
def _expire_tokens(self):
|
def _expire_tokens(self):
|
||||||
now = time.time()
|
now = time.time()
|
||||||
self._tokens = dict(filter(lambda (x,y): y[1]>now,
|
self._tokens = dict(filter(lambda x_y: x_y[1][1]>now,
|
||||||
self._tokens.items()))
|
self._tokens.items()))
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
|
@ -191,15 +191,18 @@ class ChannelUserDictionary(collections.MutableMapping):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.channels = ircutils.IrcDict()
|
self.channels = ircutils.IrcDict()
|
||||||
|
|
||||||
def __getitem__(self, (channel, id)):
|
def __getitem__(self, key):
|
||||||
|
(channel, id) = key
|
||||||
return self.channels[channel][id]
|
return self.channels[channel][id]
|
||||||
|
|
||||||
def __setitem__(self, (channel, id), v):
|
def __setitem__(self, key, v):
|
||||||
|
(channel, id) = key
|
||||||
if channel not in self.channels:
|
if channel not in self.channels:
|
||||||
self.channels[channel] = self.IdDict()
|
self.channels[channel] = self.IdDict()
|
||||||
self.channels[channel][id] = v
|
self.channels[channel][id] = v
|
||||||
|
|
||||||
def __delitem__(self, (channel, id)):
|
def __delitem__(self, key):
|
||||||
|
(channel, id) = key
|
||||||
del self.channels[channel][id]
|
del self.channels[channel][id]
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
|
4
setup.py
4
setup.py
@ -155,9 +155,7 @@ try:
|
|||||||
'fix_itertools', 'fix_itertools_imports', 'fix_long',
|
'fix_itertools', 'fix_itertools_imports', 'fix_long',
|
||||||
'fix_map', 'fix_metaclass', 'fix_methodattrs',
|
'fix_map', 'fix_metaclass', 'fix_methodattrs',
|
||||||
'fix_numliterals',
|
'fix_numliterals',
|
||||||
'fix_reduce', 'fix_renames', 'fix_repr',
|
'fix_types',
|
||||||
'fix_set_literal', 'fix_standarderror', 'fix_sys_exc',
|
|
||||||
'fix_throw', 'fix_tuple_params', 'fix_types',
|
|
||||||
'fix_unicode', 'fix_urllib', 'fix_ws_comma', 'fix_xrange',
|
'fix_unicode', 'fix_urllib', 'fix_ws_comma', 'fix_xrange',
|
||||||
'fix_xreadlines', 'fix_zip']
|
'fix_xreadlines', 'fix_zip']
|
||||||
fixers = list(map(lambda x:'lib2to3.fixes.'+x, fixer_names))
|
fixers = list(map(lambda x:'lib2to3.fixes.'+x, fixer_names))
|
||||||
|
@ -693,7 +693,7 @@ class UsersDictionary(utils.IterableMap):
|
|||||||
try:
|
try:
|
||||||
self._hostmaskCache[id].add(s)
|
self._hostmaskCache[id].add(s)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self._hostmaskCache[id] = set([s])
|
self._hostmaskCache[id] = {s}
|
||||||
return id
|
return id
|
||||||
elif len(ids) == 0:
|
elif len(ids) == 0:
|
||||||
raise KeyError(s)
|
raise KeyError(s)
|
||||||
|
@ -628,9 +628,9 @@ class Irc(IrcCommandDispatcher):
|
|||||||
__firewalled__ = {'die': None,
|
__firewalled__ = {'die': None,
|
||||||
'feedMsg': None,
|
'feedMsg': None,
|
||||||
'takeMsg': None,}
|
'takeMsg': None,}
|
||||||
_nickSetters = set(['001', '002', '003', '004', '250', '251', '252',
|
_nickSetters = {'001', '002', '003', '004', '250', '251', '252',
|
||||||
'254', '255', '265', '266', '372', '375', '376',
|
'254', '255', '265', '266', '372', '375', '376',
|
||||||
'333', '353', '332', '366', '005'])
|
'333', '353', '332', '366', '005'}
|
||||||
# We specifically want these callbacks to be common between all Ircs,
|
# We specifically want these callbacks to be common between all Ircs,
|
||||||
# that's why we don't do the normal None default with a check.
|
# that's why we don't do the normal None default with a check.
|
||||||
def __init__(self, network, callbacks=_callbacks):
|
def __init__(self, network, callbacks=_callbacks):
|
||||||
|
@ -52,7 +52,8 @@ class Formatter(logging.Formatter):
|
|||||||
def formatTime(self, record, datefmt=None):
|
def formatTime(self, record, datefmt=None):
|
||||||
return timestamp(record.created)
|
return timestamp(record.created)
|
||||||
|
|
||||||
def formatException(self, (E, e, tb)):
|
def formatException(self, exc_info):
|
||||||
|
(E, e, tb) = exc_info
|
||||||
for exn in deadlyExceptions:
|
for exn in deadlyExceptions:
|
||||||
if issubclass(e.__class__, exn):
|
if issubclass(e.__class__, exn):
|
||||||
raise
|
raise
|
||||||
@ -113,7 +114,7 @@ class StdoutStreamHandler(logging.StreamHandler):
|
|||||||
exception('Uncaught exception in StdoutStreamHandler:')
|
exception('Uncaught exception in StdoutStreamHandler:')
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
self.setLevel(sys.maxint) # Just in case.
|
self.setLevel(sys.maxsize) # Just in case.
|
||||||
_logger.removeHandler(self)
|
_logger.removeHandler(self)
|
||||||
logging._acquireLock()
|
logging._acquireLock()
|
||||||
try:
|
try:
|
||||||
@ -142,7 +143,8 @@ class ColorizedFormatter(Formatter):
|
|||||||
# This was necessary because these variables aren't defined until later.
|
# This was necessary because these variables aren't defined until later.
|
||||||
# The staticmethod is necessary because they get treated like methods.
|
# The staticmethod is necessary because they get treated like methods.
|
||||||
_fmtConf = staticmethod(lambda : conf.supybot.log.stdout.format())
|
_fmtConf = staticmethod(lambda : conf.supybot.log.stdout.format())
|
||||||
def formatException(self, (E, e, tb)):
|
def formatException(self, exc_info):
|
||||||
|
(E, e, tb) = exc_info
|
||||||
if conf.supybot.log.stdout.colorized():
|
if conf.supybot.log.stdout.colorized():
|
||||||
return ''.join([ansi.RED,
|
return ''.join([ansi.RED,
|
||||||
Formatter.formatException(self, (E, e, tb)),
|
Formatter.formatException(self, (E, e, tb)),
|
||||||
|
@ -37,7 +37,7 @@ class shlex:
|
|||||||
def push_token(self, tok):
|
def push_token(self, tok):
|
||||||
"Push a token onto the stack popped by the get_token method"
|
"Push a token onto the stack popped by the get_token method"
|
||||||
if self.debug >= 1:
|
if self.debug >= 1:
|
||||||
print("shlex: pushing token " + `tok`)
|
print("shlex: pushing token " + repr(tok))
|
||||||
self.pushback = [tok] + self.pushback
|
self.pushback = [tok] + self.pushback
|
||||||
|
|
||||||
def push_source(self, newstream, newfile=None):
|
def push_source(self, newstream, newfile=None):
|
||||||
@ -68,7 +68,7 @@ class shlex:
|
|||||||
tok = self.pushback[0]
|
tok = self.pushback[0]
|
||||||
self.pushback = self.pushback[1:]
|
self.pushback = self.pushback[1:]
|
||||||
if self.debug >= 1:
|
if self.debug >= 1:
|
||||||
print("shlex: popping token " + `tok`)
|
print("shlex: popping token " + repr(tok))
|
||||||
return tok
|
return tok
|
||||||
# No pushback. Get a token.
|
# No pushback. Get a token.
|
||||||
raw = self.read_token()
|
raw = self.read_token()
|
||||||
@ -89,7 +89,7 @@ class shlex:
|
|||||||
# Neither inclusion nor EOF
|
# Neither inclusion nor EOF
|
||||||
if self.debug >= 1:
|
if self.debug >= 1:
|
||||||
if raw:
|
if raw:
|
||||||
print("shlex: token=" + `raw`)
|
print("shlex: token=" + repr(raw))
|
||||||
else:
|
else:
|
||||||
print("shlex: token=EOF")
|
print("shlex: token=EOF")
|
||||||
return raw
|
return raw
|
||||||
@ -180,7 +180,7 @@ class shlex:
|
|||||||
self.token = ''
|
self.token = ''
|
||||||
if self.debug > 1:
|
if self.debug > 1:
|
||||||
if result:
|
if result:
|
||||||
print("shlex: raw token=" + `result`)
|
print("shlex: raw token=" + repr(result))
|
||||||
else:
|
else:
|
||||||
print("shlex: raw token=EOF")
|
print("shlex: raw token=EOF")
|
||||||
return result
|
return result
|
||||||
|
@ -154,7 +154,8 @@ class RingBuffer(object):
|
|||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
return (self.maxSize, self.full, self.i, self.L)
|
return (self.maxSize, self.full, self.i, self.L)
|
||||||
|
|
||||||
def __setstate__(self, (maxSize, full, i, L)):
|
def __setstate__(self, state):
|
||||||
|
(maxSize, full, i, L) = state
|
||||||
self.maxSize = maxSize
|
self.maxSize = maxSize
|
||||||
self.full = full
|
self.full = full
|
||||||
self.i = i
|
self.i = i
|
||||||
@ -281,7 +282,8 @@ class queue(object):
|
|||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
return (list(self),)
|
return (list(self),)
|
||||||
|
|
||||||
def __setstate__(self, (L,)):
|
def __setstate__(self, state):
|
||||||
|
(L,) = state
|
||||||
L.reverse()
|
L.reverse()
|
||||||
self.front = L
|
self.front = L
|
||||||
self.back = []
|
self.back = []
|
||||||
@ -365,7 +367,8 @@ class MaxLengthQueue(queue):
|
|||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
return (self.length, queue.__getstate__(self))
|
return (self.length, queue.__getstate__(self))
|
||||||
|
|
||||||
def __setstate__(self, (length, q)):
|
def __setstate__(self, state):
|
||||||
|
(length, q) = state
|
||||||
self.length = length
|
self.length = length
|
||||||
queue.__setstate__(self, q)
|
queue.__setstate__(self, q)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user