mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-10 20:22:36 +01: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)
|
||||
if 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:
|
||||
irc.error(_('I\'m already too close to maximum number of '
|
||||
'channels for this network.'), Raise=True)
|
||||
|
@ -279,7 +279,7 @@ class Channel(callbacks.Plugin):
|
||||
irc.error(_('I cowardly refuse to kick myself.'), Raise=True)
|
||||
if not reason:
|
||||
reason = msg.nick
|
||||
kicklen = irc.state.supported.get('kicklen', sys.maxint)
|
||||
kicklen = irc.state.supported.get('kicklen', sys.maxsize)
|
||||
if len(reason) > kicklen:
|
||||
irc.error(_('The reason you gave is longer than the allowed '
|
||||
'length for a KICK reason on this server.'),
|
||||
|
@ -163,7 +163,7 @@ class Nickometer(callbacks.Plugin):
|
||||
# Punish k3wlt0k
|
||||
k3wlt0k_weights = (5, 5, 2, 5, 2, 3, 1, 2, 2, 2)
|
||||
for i in range(len(k3wlt0k_weights)):
|
||||
hits=re.findall(`i`, nick)
|
||||
hits=re.findall(repr(i), nick)
|
||||
if (hits and len(hits)>0):
|
||||
score += self.punish(k3wlt0k_weights[i] * len(hits) * 30,
|
||||
'%s occurrences of %s ' % (len(hits), i))
|
||||
@ -225,7 +225,7 @@ class Nickometer(callbacks.Plugin):
|
||||
(1 - 1 / (1 + score / 5.0)) // 2
|
||||
|
||||
# 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%%.') %
|
||||
(originalNick, score_string))
|
||||
|
@ -415,7 +415,7 @@ class User(callbacks.Plugin):
|
||||
|
||||
def _expire_tokens(self):
|
||||
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()))
|
||||
|
||||
@internationalizeDocstring
|
||||
|
@ -191,15 +191,18 @@ class ChannelUserDictionary(collections.MutableMapping):
|
||||
def __init__(self):
|
||||
self.channels = ircutils.IrcDict()
|
||||
|
||||
def __getitem__(self, (channel, id)):
|
||||
def __getitem__(self, key):
|
||||
(channel, id) = key
|
||||
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:
|
||||
self.channels[channel] = self.IdDict()
|
||||
self.channels[channel][id] = v
|
||||
|
||||
def __delitem__(self, (channel, id)):
|
||||
def __delitem__(self, key):
|
||||
(channel, id) = key
|
||||
del self.channels[channel][id]
|
||||
|
||||
def __iter__(self):
|
||||
|
4
setup.py
4
setup.py
@ -155,9 +155,7 @@ try:
|
||||
'fix_itertools', 'fix_itertools_imports', 'fix_long',
|
||||
'fix_map', 'fix_metaclass', 'fix_methodattrs',
|
||||
'fix_numliterals',
|
||||
'fix_reduce', 'fix_renames', 'fix_repr',
|
||||
'fix_set_literal', 'fix_standarderror', 'fix_sys_exc',
|
||||
'fix_throw', 'fix_tuple_params', 'fix_types',
|
||||
'fix_types',
|
||||
'fix_unicode', 'fix_urllib', 'fix_ws_comma', 'fix_xrange',
|
||||
'fix_xreadlines', 'fix_zip']
|
||||
fixers = list(map(lambda x:'lib2to3.fixes.'+x, fixer_names))
|
||||
|
@ -693,7 +693,7 @@ class UsersDictionary(utils.IterableMap):
|
||||
try:
|
||||
self._hostmaskCache[id].add(s)
|
||||
except KeyError:
|
||||
self._hostmaskCache[id] = set([s])
|
||||
self._hostmaskCache[id] = {s}
|
||||
return id
|
||||
elif len(ids) == 0:
|
||||
raise KeyError(s)
|
||||
|
@ -628,9 +628,9 @@ class Irc(IrcCommandDispatcher):
|
||||
__firewalled__ = {'die': None,
|
||||
'feedMsg': 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',
|
||||
'333', '353', '332', '366', '005'])
|
||||
'333', '353', '332', '366', '005'}
|
||||
# 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.
|
||||
def __init__(self, network, callbacks=_callbacks):
|
||||
|
@ -52,7 +52,8 @@ class Formatter(logging.Formatter):
|
||||
def formatTime(self, record, datefmt=None):
|
||||
return timestamp(record.created)
|
||||
|
||||
def formatException(self, (E, e, tb)):
|
||||
def formatException(self, exc_info):
|
||||
(E, e, tb) = exc_info
|
||||
for exn in deadlyExceptions:
|
||||
if issubclass(e.__class__, exn):
|
||||
raise
|
||||
@ -113,7 +114,7 @@ class StdoutStreamHandler(logging.StreamHandler):
|
||||
exception('Uncaught exception in StdoutStreamHandler:')
|
||||
|
||||
def disable(self):
|
||||
self.setLevel(sys.maxint) # Just in case.
|
||||
self.setLevel(sys.maxsize) # Just in case.
|
||||
_logger.removeHandler(self)
|
||||
logging._acquireLock()
|
||||
try:
|
||||
@ -142,7 +143,8 @@ class ColorizedFormatter(Formatter):
|
||||
# This was necessary because these variables aren't defined until later.
|
||||
# The staticmethod is necessary because they get treated like methods.
|
||||
_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():
|
||||
return ''.join([ansi.RED,
|
||||
Formatter.formatException(self, (E, e, tb)),
|
||||
|
@ -37,7 +37,7 @@ class shlex:
|
||||
def push_token(self, tok):
|
||||
"Push a token onto the stack popped by the get_token method"
|
||||
if self.debug >= 1:
|
||||
print("shlex: pushing token " + `tok`)
|
||||
print("shlex: pushing token " + repr(tok))
|
||||
self.pushback = [tok] + self.pushback
|
||||
|
||||
def push_source(self, newstream, newfile=None):
|
||||
@ -68,7 +68,7 @@ class shlex:
|
||||
tok = self.pushback[0]
|
||||
self.pushback = self.pushback[1:]
|
||||
if self.debug >= 1:
|
||||
print("shlex: popping token " + `tok`)
|
||||
print("shlex: popping token " + repr(tok))
|
||||
return tok
|
||||
# No pushback. Get a token.
|
||||
raw = self.read_token()
|
||||
@ -89,7 +89,7 @@ class shlex:
|
||||
# Neither inclusion nor EOF
|
||||
if self.debug >= 1:
|
||||
if raw:
|
||||
print("shlex: token=" + `raw`)
|
||||
print("shlex: token=" + repr(raw))
|
||||
else:
|
||||
print("shlex: token=EOF")
|
||||
return raw
|
||||
@ -180,7 +180,7 @@ class shlex:
|
||||
self.token = ''
|
||||
if self.debug > 1:
|
||||
if result:
|
||||
print("shlex: raw token=" + `result`)
|
||||
print("shlex: raw token=" + repr(result))
|
||||
else:
|
||||
print("shlex: raw token=EOF")
|
||||
return result
|
||||
|
@ -154,7 +154,8 @@ class RingBuffer(object):
|
||||
def __getstate__(self):
|
||||
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.full = full
|
||||
self.i = i
|
||||
@ -281,7 +282,8 @@ class queue(object):
|
||||
def __getstate__(self):
|
||||
return (list(self),)
|
||||
|
||||
def __setstate__(self, (L,)):
|
||||
def __setstate__(self, state):
|
||||
(L,) = state
|
||||
L.reverse()
|
||||
self.front = L
|
||||
self.back = []
|
||||
@ -365,7 +367,8 @@ class MaxLengthQueue(queue):
|
||||
def __getstate__(self):
|
||||
return (self.length, queue.__getstate__(self))
|
||||
|
||||
def __setstate__(self, (length, q)):
|
||||
def __setstate__(self, state):
|
||||
(length, q) = state
|
||||
self.length = length
|
||||
queue.__setstate__(self, q)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user