mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +01:00
utils.gen.* functions shouldn't explicitly be called since they're all in the utils namespace.
This commit is contained in:
parent
0ba3b076a5
commit
90c000793d
@ -154,7 +154,7 @@ class Admin(callbacks.Plugin):
|
|||||||
"""
|
"""
|
||||||
L = irc.state.channels.keys()
|
L = irc.state.channels.keys()
|
||||||
if L:
|
if L:
|
||||||
utils.gen.sortBy(ircutils.toLower, L)
|
utils.sortBy(ircutils.toLower, L)
|
||||||
irc.reply(format('%L', L))
|
irc.reply(format('%L', L))
|
||||||
else:
|
else:
|
||||||
irc.reply('I\'m not currently in any channels.')
|
irc.reply('I\'m not currently in any channels.')
|
||||||
|
@ -36,7 +36,7 @@ import supybot.callbacks as callbacks
|
|||||||
|
|
||||||
class Babelfish(callbacks.Plugin):
|
class Babelfish(callbacks.Plugin):
|
||||||
threaded = True
|
threaded = True
|
||||||
_abbrevs = utils.gen.abbrev(map(str.lower, babelfish.available_languages))
|
_abbrevs = utils.abbrev(map(str.lower, babelfish.available_languages))
|
||||||
_abbrevs['de'] = 'german'
|
_abbrevs['de'] = 'german'
|
||||||
_abbrevs['jp'] = 'japanese'
|
_abbrevs['jp'] = 'japanese'
|
||||||
_abbrevs['kr'] = 'korean'
|
_abbrevs['kr'] = 'korean'
|
||||||
|
@ -784,7 +784,7 @@ class Channel(callbacks.Plugin):
|
|||||||
message isn't sent in the channel itself.
|
message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
L = list(irc.state.channels[channel].users)
|
L = list(irc.state.channels[channel].users)
|
||||||
utils.gen.sortBy(str.lower, L)
|
utils.sortBy(str.lower, L)
|
||||||
irc.reply(utils.str.commaAndify(L))
|
irc.reply(utils.str.commaAndify(L))
|
||||||
nicks = wrap(nicks, ['inChannel']) # XXX Check that the caller is in chan.
|
nicks = wrap(nicks, ['inChannel']) # XXX Check that the caller is in chan.
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ class Config(callbacks.Plugin):
|
|||||||
if v._added and not all(ircutils.isChannel, v._added):
|
if v._added and not all(ircutils.isChannel, v._added):
|
||||||
vname = '@' + vname
|
vname = '@' + vname
|
||||||
L.append(vname)
|
L.append(vname)
|
||||||
utils.gen.sortBy(str.lower, L)
|
utils.sortBy(str.lower, L)
|
||||||
return L
|
return L
|
||||||
|
|
||||||
def list(self, irc, msg, args, group):
|
def list(self, irc, msg, args, group):
|
||||||
|
@ -109,7 +109,7 @@ class Dict(callbacks.Plugin):
|
|||||||
db = ircutils.bold(db)
|
db = ircutils.bold(db)
|
||||||
s = utils.str.normalizeWhitespace(s).rstrip(';.,')
|
s = utils.str.normalizeWhitespace(s).rstrip(';.,')
|
||||||
L.append('%s: %s' % (db, s))
|
L.append('%s: %s' % (db, s))
|
||||||
utils.gen.sortBy(len, L)
|
utils.sortBy(len, L)
|
||||||
if dictionary == '*' and len(dbs) > 1:
|
if dictionary == '*' and len(dbs) > 1:
|
||||||
s = format('%L responded: %s', list(dbs), '; '.join(L))
|
s = format('%L responded: %s', list(dbs), '; '.join(L))
|
||||||
else:
|
else:
|
||||||
|
@ -184,7 +184,7 @@ class Format(callbacks.Plugin):
|
|||||||
s %= tuple(args)
|
s %= tuple(args)
|
||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
except TypeError, e:
|
except TypeError, e:
|
||||||
self.log.debug(utils.gen.exnToString(e))
|
self.log.debug(utils.exnToString(e))
|
||||||
irc.error('Not enough arguments for the format string.',Raise=True)
|
irc.error('Not enough arguments for the format string.',Raise=True)
|
||||||
|
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ class Karma(callbacks.Plugin):
|
|||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
karma = wrap(karma, ['channel', any('something')])
|
karma = wrap(karma, ['channel', any('something')])
|
||||||
|
|
||||||
_mostAbbrev = utils.gen.abbrev(['increased', 'decreased', 'active'])
|
_mostAbbrev = utils.abbrev(['increased', 'decreased', 'active'])
|
||||||
def most(self, irc, msg, args, channel, kind):
|
def most(self, irc, msg, args, channel, kind):
|
||||||
"""[<channel>] {increased,decreased,active}
|
"""[<channel>] {increased,decreased,active}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ class Math(callbacks.Plugin):
|
|||||||
except NameError, e:
|
except NameError, e:
|
||||||
irc.error('%s is not a defined function.' % str(e).split()[1])
|
irc.error('%s is not a defined function.' % str(e).split()[1])
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
irc.error(utils.gen.exnToString(e))
|
irc.error(utils.exnToString(e))
|
||||||
icalc = wrap(icalc, [('checkCapability', 'trusted'), 'text'])
|
icalc = wrap(icalc, [('checkCapability', 'trusted'), 'text'])
|
||||||
|
|
||||||
_rpnEnv = {
|
_rpnEnv = {
|
||||||
|
@ -76,7 +76,7 @@ class Misc(callbacks.Plugin):
|
|||||||
irc.reply('You\'ve given me %s invalid commands within the last '
|
irc.reply('You\'ve given me %s invalid commands within the last '
|
||||||
'minute; I\'m now ignoring you for %s.' %
|
'minute; I\'m now ignoring you for %s.' %
|
||||||
(maximum,
|
(maximum,
|
||||||
utils.gen.timeElapsed(punishment, seconds=False)))
|
utils.timeElapsed(punishment, seconds=False)))
|
||||||
return
|
return
|
||||||
# Now, for normal handling.
|
# Now, for normal handling.
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
@ -456,7 +456,7 @@ class Misc(callbacks.Plugin):
|
|||||||
L = module.__contributors__.items()
|
L = module.__contributors__.items()
|
||||||
def negativeSecondElement(x):
|
def negativeSecondElement(x):
|
||||||
return -len(x[1])
|
return -len(x[1])
|
||||||
utils.gen.sortBy(negativeSecondElement, L)
|
utils.sortBy(negativeSecondElement, L)
|
||||||
return [t[0] for t in L]
|
return [t[0] for t in L]
|
||||||
def buildPeopleString(module):
|
def buildPeopleString(module):
|
||||||
"""
|
"""
|
||||||
|
@ -182,7 +182,7 @@ class Network(callbacks.Plugin):
|
|||||||
L = ['isn\'t on any non-secret channels']
|
L = ['isn\'t on any non-secret channels']
|
||||||
channels = format('%L', L)
|
channels = format('%L', L)
|
||||||
if '317' in d:
|
if '317' in d:
|
||||||
idle = utils.gen.timeElapsed(d['317'].args[2])
|
idle = utils.timeElapsed(d['317'].args[2])
|
||||||
signon = time.strftime(conf.supybot.reply.format.time(),
|
signon = time.strftime(conf.supybot.reply.format.time(),
|
||||||
time.localtime(float(d['317'].args[3])))
|
time.localtime(float(d['317'].args[3])))
|
||||||
else:
|
else:
|
||||||
@ -241,7 +241,7 @@ class Network(callbacks.Plugin):
|
|||||||
Returns the networks to which the bot is currently connected.
|
Returns the networks to which the bot is currently connected.
|
||||||
"""
|
"""
|
||||||
L = ['%s: %s' % (ircd.network, ircd.server) for ircd in world.ircs]
|
L = ['%s: %s' % (ircd.network, ircd.server) for ircd in world.ircs]
|
||||||
utils.gen.sortBy(str.lower, L)
|
utils.sortBy(str.lower, L)
|
||||||
irc.reply(format('%L', L))
|
irc.reply(format('%L', L))
|
||||||
networks = wrap(networks)
|
networks = wrap(networks)
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ class Owner(callbacks.Plugin):
|
|||||||
try:
|
try:
|
||||||
m = ircmsgs.IrcMsg(s)
|
m = ircmsgs.IrcMsg(s)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
irc.error(utils.gen.exnToString(e))
|
irc.error(utils.exnToString(e))
|
||||||
else:
|
else:
|
||||||
irc.queueMsg(m)
|
irc.queueMsg(m)
|
||||||
irc.noReply()
|
irc.noReply()
|
||||||
|
@ -99,7 +99,7 @@ class Status(callbacks.Plugin):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
elapsed = time.time() - self.connected[irc.getRealIrc()]
|
elapsed = time.time() - self.connected[irc.getRealIrc()]
|
||||||
timeElapsed = utils.gen.timeElapsed(elapsed)
|
timeElapsed = utils.timeElapsed(elapsed)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
timeElapsed = 'an indeterminate amount of time'
|
timeElapsed = 'an indeterminate amount of time'
|
||||||
irc.reply('I have received %s messages for a total of %s bytes. '
|
irc.reply('I have received %s messages for a total of %s bytes. '
|
||||||
@ -200,7 +200,7 @@ class Status(callbacks.Plugin):
|
|||||||
Returns the amount of time the bot has been running.
|
Returns the amount of time the bot has been running.
|
||||||
"""
|
"""
|
||||||
response = 'I have been running for %s.' % \
|
response = 'I have been running for %s.' % \
|
||||||
utils.gen.timeElapsed(time.time() - world.startedAt)
|
utils.timeElapsed(time.time() - world.startedAt)
|
||||||
irc.reply(response)
|
irc.reply(response)
|
||||||
uptime = wrap(uptime)
|
uptime = wrap(uptime)
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class User(callbacks.Plugin):
|
|||||||
else:
|
else:
|
||||||
users.append(u.name)
|
users.append(u.name)
|
||||||
if users:
|
if users:
|
||||||
utils.gen.sortBy(str.lower, users)
|
utils.sortBy(str.lower, users)
|
||||||
irc.reply(format('%L', users))
|
irc.reply(format('%L', users))
|
||||||
else:
|
else:
|
||||||
if predicates:
|
if predicates:
|
||||||
|
@ -279,11 +279,11 @@ class ChannelUserDB(ChannelUserDictionary):
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.warning('Invalid line #%s in %s.',
|
log.warning('Invalid line #%s in %s.',
|
||||||
lineno, self.__class__.__name__)
|
lineno, self.__class__.__name__)
|
||||||
log.debug('Exception: %s', utils.gen.exnToString(e))
|
log.debug('Exception: %s', utils.exnToString(e))
|
||||||
except Exception, e: # This catches exceptions from csv.reader.
|
except Exception, e: # This catches exceptions from csv.reader.
|
||||||
log.warning('Invalid line #%s in %s.',
|
log.warning('Invalid line #%s in %s.',
|
||||||
lineno, self.__class__.__name__)
|
lineno, self.__class__.__name__)
|
||||||
log.debug('Exception: %s', utils.gen.exnToString(e))
|
log.debug('Exception: %s', utils.exnToString(e))
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
fd = utils.file.AtomicFile(self.filename, makeBackupIfSmaller=False)
|
fd = utils.file.AtomicFile(self.filename, makeBackupIfSmaller=False)
|
||||||
|
@ -89,7 +89,7 @@ class Debug(callbacks.Privmsg):
|
|||||||
self._evalEnv['_'] = x
|
self._evalEnv['_'] = x
|
||||||
irc.reply(repr(x))
|
irc.reply(repr(x))
|
||||||
except SyntaxError, e:
|
except SyntaxError, e:
|
||||||
irc.reply(format('%s: %q', utils.gen.exnToString(e), s))
|
irc.reply(format('%s: %q', utils.exnToString(e), s))
|
||||||
eval = wrap(eval, ['text'])
|
eval = wrap(eval, ['text'])
|
||||||
|
|
||||||
def _exec(self, irc, msg, args, s):
|
def _exec(self, irc, msg, args, s):
|
||||||
|
@ -647,7 +647,7 @@ class IrcObjectProxy(RichReplyMethods):
|
|||||||
cb.log.exception('Uncaught exception in %s.%s:',
|
cb.log.exception('Uncaught exception in %s.%s:',
|
||||||
cb.name(), name)
|
cb.name(), name)
|
||||||
if conf.supybot.reply.error.detailed():
|
if conf.supybot.reply.error.detailed():
|
||||||
return self.error(utils.gen.exnToString(e))
|
return self.error(utils.exnToString(e))
|
||||||
else:
|
else:
|
||||||
return self.replyError()
|
return self.replyError()
|
||||||
finally:
|
finally:
|
||||||
@ -1055,7 +1055,7 @@ class Commands(object):
|
|||||||
except (getopt.GetoptError, ArgumentError):
|
except (getopt.GetoptError, ArgumentError):
|
||||||
irc.reply(formatArgumentError(method, name=name))
|
irc.reply(formatArgumentError(method, name=name))
|
||||||
except (SyntaxError, Error), e:
|
except (SyntaxError, Error), e:
|
||||||
self.log.debug('Error return: %s', utils.gen.exnToString(e))
|
self.log.debug('Error return: %s', utils.exnToString(e))
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
elapsed = time.time() - start
|
elapsed = time.time() - start
|
||||||
|
|
||||||
@ -1128,7 +1128,7 @@ class PluginMixin(irclib.IrcCallback):
|
|||||||
handleBadArgs()
|
handleBadArgs()
|
||||||
else:
|
else:
|
||||||
handleBadArgs()
|
handleBadArgs()
|
||||||
dispatcher = utils.gen.changeFunctionName(dispatcher, canonicalname)
|
dispatcher = utils.changeFunctionName(dispatcher, canonicalname)
|
||||||
if self._original:
|
if self._original:
|
||||||
dispatcher.__doc__ = self._original.__doc__
|
dispatcher.__doc__ = self._original.__doc__
|
||||||
dispatcher.isDispatcher = False
|
dispatcher.isDispatcher = False
|
||||||
@ -1287,7 +1287,7 @@ class PluginRegexp(Plugin):
|
|||||||
if catchErrors:
|
if catchErrors:
|
||||||
self.log.exception('Uncaught exception in callCommand:')
|
self.log.exception('Uncaught exception in callCommand:')
|
||||||
if conf.supybot.reply.error.detailed():
|
if conf.supybot.reply.error.detailed():
|
||||||
irc.error(utils.gen.exnToString(e))
|
irc.error(utils.exnToString(e))
|
||||||
else:
|
else:
|
||||||
irc.replyError()
|
irc.replyError()
|
||||||
else:
|
else:
|
||||||
|
@ -65,7 +65,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.gen.changeFunctionName(newf, f.func_name, f.__doc__)
|
return utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||||
|
|
||||||
class UrlSnarfThread(world.SupyThread):
|
class UrlSnarfThread(world.SupyThread):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -79,7 +79,7 @@ class UrlSnarfThread(world.SupyThread):
|
|||||||
try:
|
try:
|
||||||
super(UrlSnarfThread, self).run()
|
super(UrlSnarfThread, self).run()
|
||||||
except utils.web.Error, e:
|
except utils.web.Error, e:
|
||||||
log.debug('Exception in urlSnarfer: %s' % utils.gen.exnToString(e))
|
log.debug('Exception in urlSnarfer: %s' % utils.exnToString(e))
|
||||||
|
|
||||||
class SnarfQueue(ircutils.FloodQueue):
|
class SnarfQueue(ircutils.FloodQueue):
|
||||||
timeout = conf.supybot.snarfThrottle
|
timeout = conf.supybot.snarfThrottle
|
||||||
@ -133,7 +133,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.gen.changeFunctionName(newf, f.func_name, f.__doc__)
|
newf = utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||||
return newf
|
return newf
|
||||||
|
|
||||||
|
|
||||||
@ -521,7 +521,7 @@ def getLiteral(irc, msg, args, state, literals, errmsg=None):
|
|||||||
# ??? Should we allow abbreviations?
|
# ??? Should we allow abbreviations?
|
||||||
if isinstance(literals, basestring):
|
if isinstance(literals, basestring):
|
||||||
literals = (literals,)
|
literals = (literals,)
|
||||||
abbrevs = utils.gen.abbrev(literals)
|
abbrevs = utils.abbrev(literals)
|
||||||
if args[0] in abbrevs:
|
if args[0] in abbrevs:
|
||||||
state.args.append(abbrevs[args.pop(0)])
|
state.args.append(abbrevs[args.pop(0)])
|
||||||
elif errmsg is not None:
|
elif errmsg is not None:
|
||||||
@ -702,7 +702,7 @@ class optional(additional):
|
|||||||
try:
|
try:
|
||||||
super(optional, self).__call__(irc, msg, args, state)
|
super(optional, self).__call__(irc, msg, args, state)
|
||||||
except (callbacks.ArgumentError, callbacks.Error), e:
|
except (callbacks.ArgumentError, callbacks.Error), e:
|
||||||
log.debug('Got %s, returning default.', utils.gen.exnToString(e))
|
log.debug('Got %s, returning default.', utils.exnToString(e))
|
||||||
setDefault(state, self.default)
|
setDefault(state, self.default)
|
||||||
|
|
||||||
class any(context):
|
class any(context):
|
||||||
@ -722,8 +722,7 @@ class any(context):
|
|||||||
if not self.continueOnError:
|
if not self.continueOnError:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
log.debug('Got %s, returning default.',
|
log.debug('Got %s, returning default.', utils.exnToString(e))
|
||||||
utils.gen.exnToString(e))
|
|
||||||
pass
|
pass
|
||||||
state.args.append(st.args)
|
state.args.append(st.args)
|
||||||
|
|
||||||
@ -879,8 +878,7 @@ def wrap(f, specList=[], **kw):
|
|||||||
funcArgs = inspect.getargs(f.func_code)[0][len(self.commandArgs):]
|
funcArgs = inspect.getargs(f.func_code)[0][len(self.commandArgs):]
|
||||||
self.log.error('Extra args: %s', funcArgs)
|
self.log.error('Extra args: %s', funcArgs)
|
||||||
raise
|
raise
|
||||||
return utils.gen.changeFunctionName(newf, f.func_name, f.__doc__)
|
return utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
# Contexts.
|
# Contexts.
|
||||||
|
@ -300,11 +300,11 @@ registerChannelValue(supybot.reply.format.time.elapsed, 'short',
|
|||||||
registry.Boolean(False, """Determines whether elapsed times will be given
|
registry.Boolean(False, """Determines whether elapsed times will be given
|
||||||
as "1 day, 2 hours, 3 minutes, and 15 seconds" or as "1d 2h 3m 15s"."""))
|
as "1 day, 2 hours, 3 minutes, and 15 seconds" or as "1d 2h 3m 15s"."""))
|
||||||
|
|
||||||
originalTimeElapsed = utils.gen.timeElapsed
|
originalTimeElapsed = utils.timeElapsed
|
||||||
def timeElapsed(*args, **kwargs):
|
def timeElapsed(*args, **kwargs):
|
||||||
kwargs['short'] = supybot.reply.format.time.elapsed.short()
|
kwargs['short'] = supybot.reply.format.time.elapsed.short()
|
||||||
return originalTimeElapsed(*args, **kwargs)
|
return originalTimeElapsed(*args, **kwargs)
|
||||||
utils.gen.timeElapsed = timeElapsed
|
utils.timeElapsed = timeElapsed
|
||||||
|
|
||||||
registerGlobalValue(supybot.reply, 'maximumLength',
|
registerGlobalValue(supybot.reply, 'maximumLength',
|
||||||
registry.Integer(512*256, """Determines the absolute maximum length of the
|
registry.Integer(512*256, """Determines the absolute maximum length of the
|
||||||
|
@ -138,13 +138,13 @@ class Log(object):
|
|||||||
if isinstance(e, socket.gaierror):
|
if isinstance(e, socket.gaierror):
|
||||||
e = e.args[1]
|
e = e.args[1]
|
||||||
else:
|
else:
|
||||||
e = utils.gen.exnToString(e)
|
e = utils.exnToString(e)
|
||||||
self.warning('Error connecting to %s: %s', server, e)
|
self.warning('Error connecting to %s: %s', server, e)
|
||||||
|
|
||||||
def disconnect(self, server, e=None):
|
def disconnect(self, server, e=None):
|
||||||
if e:
|
if e:
|
||||||
if isinstance(e, Exception):
|
if isinstance(e, Exception):
|
||||||
e = utils.gen.exnToString(e)
|
e = utils.exnToString(e)
|
||||||
else:
|
else:
|
||||||
e = str(e)
|
e = str(e)
|
||||||
if not e.endswith('.'):
|
if not e.endswith('.'):
|
||||||
|
12
src/ircdb.py
12
src/ircdb.py
@ -249,7 +249,7 @@ class IrcUser(object):
|
|||||||
"""Sets the user's password."""
|
"""Sets the user's password."""
|
||||||
if hashed or self.hashed:
|
if hashed or self.hashed:
|
||||||
self.hashed = True
|
self.hashed = True
|
||||||
self.password = utils.gen.saltHash(password)
|
self.password = utils.saltHash(password)
|
||||||
else:
|
else:
|
||||||
self.password = password
|
self.password = password
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ class IrcUser(object):
|
|||||||
"""Checks the user's password."""
|
"""Checks the user's password."""
|
||||||
if self.hashed:
|
if self.hashed:
|
||||||
(salt, _) = self.password.split('|')
|
(salt, _) = self.password.split('|')
|
||||||
return (self.password == utils.gen.saltHash(password, salt=salt))
|
return (self.password == utils.saltHash(password, salt=salt))
|
||||||
else:
|
else:
|
||||||
return (self.password == password)
|
return (self.password == password)
|
||||||
|
|
||||||
@ -437,11 +437,11 @@ class IrcChannel(object):
|
|||||||
for capability in self.capabilities:
|
for capability in self.capabilities:
|
||||||
write('capability ' + capability)
|
write('capability ' + capability)
|
||||||
bans = self.bans.items()
|
bans = self.bans.items()
|
||||||
utils.gen.sortBy(operator.itemgetter(1), bans)
|
utils.sortBy(operator.itemgetter(1), bans)
|
||||||
for (ban, expiration) in bans:
|
for (ban, expiration) in bans:
|
||||||
write('ban %s %d' % (ban, expiration))
|
write('ban %s %d' % (ban, expiration))
|
||||||
ignores = self.ignores.items()
|
ignores = self.ignores.items()
|
||||||
utils.gen.sortBy(operator.itemgetter(1), ignores)
|
utils.sortBy(operator.itemgetter(1), ignores)
|
||||||
for (ignore, expiration) in ignores:
|
for (ignore, expiration) in ignores:
|
||||||
write('ignore %s %d' % (ignore, expiration))
|
write('ignore %s %d' % (ignore, expiration))
|
||||||
fd.write(os.linesep)
|
fd.write(os.linesep)
|
||||||
@ -578,7 +578,7 @@ class UsersDictionary(utils.IterableMap):
|
|||||||
self.flush()
|
self.flush()
|
||||||
except EnvironmentError, e:
|
except EnvironmentError, e:
|
||||||
log.error('Invalid user dictionary file, resetting to empty.')
|
log.error('Invalid user dictionary file, resetting to empty.')
|
||||||
log.error('Exact error: %s', utils.gen.exnToString(e))
|
log.error('Exact error: %s', utils.exnToString(e))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.exception('Exact error:')
|
log.exception('Exact error:')
|
||||||
finally:
|
finally:
|
||||||
@ -773,7 +773,7 @@ class ChannelsDictionary(utils.IterableMap):
|
|||||||
self.flush()
|
self.flush()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error('Invalid channel database, resetting to empty.')
|
log.error('Invalid channel database, resetting to empty.')
|
||||||
log.error('Exact error: %s', utils.gen.exnToString(e))
|
log.error('Exact error: %s', utils.exnToString(e))
|
||||||
finally:
|
finally:
|
||||||
self.noFlush = False
|
self.noFlush = False
|
||||||
|
|
||||||
|
@ -966,7 +966,7 @@ class Irc(IrcCommandDispatcher):
|
|||||||
log.debug('Last Irc, clearing callbacks.')
|
log.debug('Last Irc, clearing callbacks.')
|
||||||
self.callbacks[:] = []
|
self.callbacks[:] = []
|
||||||
else:
|
else:
|
||||||
log.warning('Irc object killed twice: %s', utils.gen.stackTrace())
|
log.warning('Irc object killed twice: %s', utils.stackTrace())
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return id(self)
|
return id(self)
|
||||||
|
@ -107,7 +107,7 @@ class StdoutStreamHandler(logging.StreamHandler):
|
|||||||
if not isinstance(record.levelname, basestring):
|
if not isinstance(record.levelname, basestring):
|
||||||
print record
|
print record
|
||||||
print record.levelname
|
print record.levelname
|
||||||
print utils.gen.stackTrace()
|
print utils.stackTrace()
|
||||||
prefixLen = len(record.levelname) + 1 # ' '
|
prefixLen = len(record.levelname) + 1 # ' '
|
||||||
s = textwrap.fill(s, width=78, subsequent_indent=' '*prefixLen)
|
s = textwrap.fill(s, width=78, subsequent_indent=' '*prefixLen)
|
||||||
s.rstrip('\r\n')
|
s.rstrip('\r\n')
|
||||||
|
@ -430,11 +430,11 @@ class String(Value):
|
|||||||
elif s[0] != s[-1] or s[0] not in '\'"':
|
elif s[0] != s[-1] or s[0] not in '\'"':
|
||||||
s = repr(s)
|
s = repr(s)
|
||||||
try:
|
try:
|
||||||
v = utils.gen.safeEval(s)
|
v = utils.safeEval(s)
|
||||||
if not isinstance(v, basestring):
|
if not isinstance(v, basestring):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
self.setValue(v)
|
self.setValue(v)
|
||||||
except ValueError: # This catches utils.gen.safeEval(s) errors too.
|
except ValueError: # This catches utils.safeEval(s) errors too.
|
||||||
self.error()
|
self.error()
|
||||||
|
|
||||||
_printable = string.printable[:-4]
|
_printable = string.printable[:-4]
|
||||||
|
@ -84,7 +84,7 @@ class TestPlugin(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
irc.reply(repr(eval(' '.join(args))))
|
irc.reply(repr(eval(' '.join(args))))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
irc.reply(utils.gen.exnToString(e))
|
irc.reply(utils.exnToString(e))
|
||||||
# Since we know we don't now need the Irc object, we just give None. This
|
# Since we know we don't now need the Irc object, we just give None. This
|
||||||
# might break if callbacks.Privmsg ever *requires* the Irc object.
|
# might break if callbacks.Privmsg ever *requires* the Irc object.
|
||||||
TestInstance = TestPlugin(None)
|
TestInstance = TestPlugin(None)
|
||||||
@ -126,7 +126,7 @@ class PluginTestCase(SupyTestCase):
|
|||||||
run = False
|
run = False
|
||||||
if run:
|
if run:
|
||||||
originalRunTest()
|
originalRunTest()
|
||||||
runTest = utils.gen.changeFunctionName(runTest, methodName)
|
runTest = utils.changeFunctionName(runTest, methodName)
|
||||||
setattr(self.__class__, methodName, runTest)
|
setattr(self.__class__, methodName, runTest)
|
||||||
SupyTestCase.__init__(self, methodName=methodName)
|
SupyTestCase.__init__(self, methodName=methodName)
|
||||||
self.originals = {}
|
self.originals = {}
|
||||||
|
@ -50,7 +50,7 @@ def abbrev(strings, d=None):
|
|||||||
yield s[:i]
|
yield s[:i]
|
||||||
if len(strings) != len(set(strings)):
|
if len(strings) != len(set(strings)):
|
||||||
raise ValueError, \
|
raise ValueError, \
|
||||||
'strings given to utils.gen.abbrev have duplicates: %r' % strings
|
'strings given to utils.abbrev have duplicates: %r' % strings
|
||||||
if d is None:
|
if d is None:
|
||||||
d = {}
|
d = {}
|
||||||
for s in strings:
|
for s in strings:
|
||||||
|
@ -97,7 +97,7 @@ class IrcMsgQueueTestCase(SupyTestCase):
|
|||||||
repr(q)
|
repr(q)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.fail('repr(q) raised an exception: %s' %
|
self.fail('repr(q) raised an exception: %s' %
|
||||||
utils.gen.exnToString(e))
|
utils.exnToString(e))
|
||||||
|
|
||||||
def testEmpty(self):
|
def testEmpty(self):
|
||||||
q = irclib.IrcMsgQueue()
|
q = irclib.IrcMsgQueue()
|
||||||
|
Loading…
Reference in New Issue
Block a user