mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-26 04:51:06 -05:00
Plugin normalization, sanitation, etc. Removed unused imports, for the most part.
This commit is contained in:
parent
70da904be2
commit
68b1d65d68
@ -29,9 +29,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import pprint
|
|
||||||
|
|
||||||
import supybot.log as log
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.ircdb as ircdb
|
import supybot.ircdb as ircdb
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
|
@ -34,7 +34,6 @@ import babelfish
|
|||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
from supybot.commands import *
|
from supybot.commands import *
|
||||||
import supybot.registry as registry
|
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Babelfish(callbacks.Privmsg):
|
class Babelfish(callbacks.Privmsg):
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.ircdb as ircdb
|
import supybot.ircdb as ircdb
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
import sets
|
|
||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
@ -37,7 +36,6 @@ import supybot.conf as conf
|
|||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
from supybot.commands import *
|
from supybot.commands import *
|
||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.registry as registry
|
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Dict(callbacks.Privmsg):
|
class Dict(callbacks.Privmsg):
|
||||||
@ -81,7 +79,7 @@ class Dict(callbacks.Privmsg):
|
|||||||
conn = dictclient.Connection(server)
|
conn = dictclient.Connection(server)
|
||||||
except socket.error, e:
|
except socket.error, e:
|
||||||
irc.error(utils.web.strError(e), Raise=True)
|
irc.error(utils.web.strError(e), Raise=True)
|
||||||
dbs = sets.Set(conn.getdbdescs())
|
dbs = set(conn.getdbdescs())
|
||||||
if words[0] in dbs:
|
if words[0] in dbs:
|
||||||
dictionary = words.pop(0)
|
dictionary = words.pop(0)
|
||||||
else:
|
else:
|
||||||
@ -97,7 +95,7 @@ class Dict(callbacks.Privmsg):
|
|||||||
irc.error('You must give a word to define.', Raise=True)
|
irc.error('You must give a word to define.', Raise=True)
|
||||||
word = ' '.join(words)
|
word = ' '.join(words)
|
||||||
definitions = conn.define(dictionary, word)
|
definitions = conn.define(dictionary, word)
|
||||||
dbs = sets.Set()
|
dbs = set()
|
||||||
if not definitions:
|
if not definitions:
|
||||||
if dictionary == '*':
|
if dictionary == '*':
|
||||||
irc.reply('No definition for %s could be found.' %
|
irc.reply('No definition for %s could be found.' %
|
||||||
|
@ -27,12 +27,9 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
import supybot.plugins as plugins
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import string
|
import string
|
||||||
import random
|
import random
|
||||||
import itertools
|
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
@ -40,7 +37,6 @@ import supybot.utils as utils
|
|||||||
from supybot.commands import *
|
from supybot.commands import *
|
||||||
import supybot.ircmsgs as ircmsgs
|
import supybot.ircmsgs as ircmsgs
|
||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.registry as registry
|
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class MyFilterProxy(object):
|
class MyFilterProxy(object):
|
||||||
@ -377,7 +373,7 @@ class Filter(callbacks.Privmsg):
|
|||||||
|
|
||||||
Returns <text> colorized like a rainbow.
|
Returns <text> colorized like a rainbow.
|
||||||
"""
|
"""
|
||||||
colors = itertools.cycle([4, 7, 8, 3, 2, 12, 6])
|
colors = utils.iter.cycle([4, 7, 8, 3, 2, 12, 6])
|
||||||
L = [self._color(c, fg=colors.next()) for c in text]
|
L = [self._color(c, fg=colors.next()) for c in text]
|
||||||
irc.reply(''.join(L) + '\x03')
|
irc.reply(''.join(L) + '\x03')
|
||||||
rainbow = wrap(rainbow, ['text'])
|
rainbow = wrap(rainbow, ['text'])
|
||||||
|
@ -27,13 +27,6 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
import supybot
|
|
||||||
|
|
||||||
__revision__ = "$Id: Format.py,v 1.19 2004/11/30 04:49:21 jemfinch Exp $"
|
|
||||||
__author__ = supybot.authors.jemfinch
|
|
||||||
|
|
||||||
import supybot.plugins as plugins
|
|
||||||
|
|
||||||
import string
|
import string
|
||||||
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
@ -42,7 +35,6 @@ from supybot.commands import *
|
|||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
|
|
||||||
def configure(advanced):
|
def configure(advanced):
|
||||||
# This will be called by setup.py to configure this module. Advanced is
|
# This will be called by setup.py to configure this module. Advanced is
|
||||||
# a bool that specifies whether the user identified himself as an advanced
|
# a bool that specifies whether the user identified himself as an advanced
|
||||||
@ -51,7 +43,6 @@ def configure(advanced):
|
|||||||
from supybot.questions import expect, anything, something, yn
|
from supybot.questions import expect, anything, something, yn
|
||||||
conf.registerPlugin('Format', True)
|
conf.registerPlugin('Format', True)
|
||||||
|
|
||||||
|
|
||||||
class Format(callbacks.Privmsg):
|
class Format(callbacks.Privmsg):
|
||||||
def bold(self, irc, msg, args, text):
|
def bold(self, irc, msg, args, text):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import getopt
|
|
||||||
|
|
||||||
import supybot.log as log
|
import supybot.log as log
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
@ -40,7 +39,6 @@ from supybot.commands import *
|
|||||||
import supybot.ircmsgs as ircmsgs
|
import supybot.ircmsgs as ircmsgs
|
||||||
import supybot.plugins as plugins
|
import supybot.plugins as plugins
|
||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.registry as registry
|
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
filename = conf.supybot.directories.data.dirize('Herald.db')
|
filename = conf.supybot.directories.data.dirize('Herald.db')
|
||||||
|
@ -31,10 +31,8 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import supybot.log as log
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
import supybot.world as world
|
|
||||||
from supybot.commands import *
|
from supybot.commands import *
|
||||||
import supybot.ircdb as ircdb
|
import supybot.ircdb as ircdb
|
||||||
import supybot.irclib as irclib
|
import supybot.irclib as irclib
|
||||||
@ -70,8 +68,8 @@ class Misc(callbacks.Privmsg):
|
|||||||
'invalid command flood.', banmask, punishment)
|
'invalid command flood.', banmask, punishment)
|
||||||
if tokens and tokens[0] == 'Error:':
|
if tokens and tokens[0] == 'Error:':
|
||||||
self.log.warning('Apparent error loop with another Supybot '
|
self.log.warning('Apparent error loop with another Supybot '
|
||||||
'observed at %s. Consider ignoring this bot '
|
'observed. Consider ignoring this bot '
|
||||||
'permanently.', log.timestamp())
|
'permanently.')
|
||||||
ircdb.ignores.add(banmask, time.time() + punishment)
|
ircdb.ignores.add(banmask, time.time() + punishment)
|
||||||
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.' %
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
import gc
|
import gc
|
||||||
import os
|
import os
|
||||||
import imp
|
|
||||||
import sre
|
import sre
|
||||||
import sys
|
import sys
|
||||||
import socket
|
import socket
|
||||||
@ -48,7 +47,6 @@ import supybot.ircmsgs as ircmsgs
|
|||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.registry as registry
|
import supybot.registry as registry
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
import supybot.structures as structures
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# supybot.commands.
|
# supybot.commands.
|
||||||
@ -365,33 +363,32 @@ class Owner(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
L = []
|
L = []
|
||||||
if level == 'high':
|
if level == 'high':
|
||||||
L.append('Regexp cache flushed: %s cleared.' %
|
L.append(format('Regexp cache flushed: %n cleared.',
|
||||||
utils.nItems('regexp', len(sre._cache)))
|
(len(sre._cache), 'regexp')))
|
||||||
sre.purge()
|
sre.purge()
|
||||||
L.append('Pattern cache flushed: %s cleared.' %
|
L.append(format('Pattern cache flushed: %n cleared.',
|
||||||
utils.nItems('compiled pattern',
|
(len(ircutils._patternCache), 'compiled pattern')))
|
||||||
len(ircutils._patternCache)))
|
|
||||||
ircutils._patternCache.clear()
|
ircutils._patternCache.clear()
|
||||||
L.append('hostmaskPatternEqual cache flushed: %s cleared.' %
|
L.append(format('hostmaskPatternEqual cache flushed: %n cleared.',
|
||||||
utils.nItems('result',
|
(len(ircutils._hostmaskPatternEqualCache),
|
||||||
len(ircutils._hostmaskPatternEqualCache)))
|
'result')))
|
||||||
ircutils._hostmaskPatternEqualCache.clear()
|
ircutils._hostmaskPatternEqualCache.clear()
|
||||||
L.append('ircdb username cache flushed: %s cleared.' %
|
L.append(format('ircdb username cache flushed: %n cleared.',
|
||||||
utils.nItems('username to id mapping',
|
(len(ircdb.users._nameCache),
|
||||||
len(ircdb.users._nameCache)))
|
'username to id mapping')))
|
||||||
ircdb.users._nameCache.clear()
|
ircdb.users._nameCache.clear()
|
||||||
L.append('ircdb hostmask cache flushed: %s cleared.' %
|
L.append(format('ircdb hostmask cache flushed: %n cleared.',
|
||||||
utils.nItems('hostmask to id mapping',
|
(len(ircdb.users._hostmaskCache),
|
||||||
len(ircdb.users._hostmaskCache)))
|
'hostmask to id mapping')))
|
||||||
ircdb.users._hostmaskCache.clear()
|
ircdb.users._hostmaskCache.clear()
|
||||||
L.append('linecache line cache flushed: %s cleared.' %
|
L.append(format('linecache line cache flushed: %s cleared.',
|
||||||
utils.nItems('line', len(linecache.cache)))
|
(len(linecache.cache, 'line'))))
|
||||||
linecache.clearcache()
|
linecache.clearcache()
|
||||||
sys.exc_clear()
|
sys.exc_clear()
|
||||||
collected = world.upkeep()
|
collected = world.upkeep()
|
||||||
if gc.garbage:
|
if gc.garbage:
|
||||||
L.append('Garbage! %r.' % gc.garbage)
|
L.append('Garbage! %r.' % gc.garbage)
|
||||||
L.append('%s collected.' % utils.nItems('object', collected))
|
L.append(format('%n collected.', (collected, 'object')))
|
||||||
irc.reply(' '.join(L))
|
irc.reply(' '.join(L))
|
||||||
upkeep = wrap(upkeep, [additional(('literal', ['high']))])
|
upkeep = wrap(upkeep, [additional(('literal', ['high']))])
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class OwnerTestCase(PluginTestCase):
|
|||||||
self.assertNotError('load Channel')
|
self.assertNotError('load Channel')
|
||||||
self.assertNotError('unload Channel')
|
self.assertNotError('unload Channel')
|
||||||
self.assertError('unload Channel')
|
self.assertError('unload Channel')
|
||||||
self.assertNotError('load CHANNEL')
|
self.assertNotError('load Channel')
|
||||||
self.assertNotError('unload CHANNEL')
|
self.assertNotError('unload CHANNEL')
|
||||||
|
|
||||||
def testDisable(self):
|
def testDisable(self):
|
||||||
|
@ -27,27 +27,22 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
import supybot.plugins as plugins
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import sets
|
|
||||||
import time
|
import time
|
||||||
import os.path
|
|
||||||
import threading
|
import threading
|
||||||
from itertools import islice, ifilter, imap
|
|
||||||
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
import supybot.world as world
|
import supybot.world as world
|
||||||
from supybot.commands import *
|
from supybot.commands import *
|
||||||
import supybot.registry as registry
|
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Status(callbacks.Privmsg):
|
class Status(callbacks.Privmsg):
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(Status, self)
|
self.__parent = super(Status, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
|
# XXX It'd be nice if these could be kept in the registry.
|
||||||
self.sentMsgs = 0
|
self.sentMsgs = 0
|
||||||
self.recvdMsgs = 0
|
self.recvdMsgs = 0
|
||||||
self.sentBytes = 0
|
self.sentBytes = 0
|
||||||
@ -77,9 +72,8 @@ class Status(callbacks.Privmsg):
|
|||||||
networks.setdefault(Irc.network, []).append(Irc.nick)
|
networks.setdefault(Irc.network, []).append(Irc.nick)
|
||||||
networks = networks.items()
|
networks = networks.items()
|
||||||
networks.sort()
|
networks.sort()
|
||||||
networks = ['%s as %s' % (net, utils.str.commaAndify(nicks))
|
networks = [format('%s as %L', net, nicks) for (net,nicks) in networks]
|
||||||
for (net, nicks) in networks]
|
L = [format('I am connected to %L.', networks)]
|
||||||
L = ['I am connected to %s.' % utils.str.commaAndify(networks)]
|
|
||||||
if world.profiling:
|
if world.profiling:
|
||||||
L.append('I am currently in code profiling mode.')
|
L.append('I am currently in code profiling mode.')
|
||||||
irc.reply(' '.join(L))
|
irc.reply(' '.join(L))
|
||||||
@ -92,11 +86,9 @@ class Status(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
threads = [t.getName() for t in threading.enumerate()]
|
threads = [t.getName() for t in threading.enumerate()]
|
||||||
threads.sort()
|
threads.sort()
|
||||||
s = 'I have spawned %s; %s %s still currently active: %s.' % \
|
s = format('I have spawned %n; %n %b still currently active: %L.',
|
||||||
(utils.str.nItems('thread', world.threadsSpawned),
|
(world.threadsSpawned, 'thread'),
|
||||||
utils.str.nItems('thread', len(threads)),
|
(len(threads), 'thread'), len(threads), threads)
|
||||||
utils.str.be(len(threads)),
|
|
||||||
utils.str.commaAndify(threads))
|
|
||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
threads = wrap(threads)
|
threads = wrap(threads)
|
||||||
|
|
||||||
@ -139,9 +131,9 @@ class Status(callbacks.Privmsg):
|
|||||||
'of system time, for a total of %.2f seconds of CPU ' \
|
'of system time, for a total of %.2f seconds of CPU ' \
|
||||||
'time. %s' % (user, system, user + system, children)
|
'time. %s' % (user, system, user + system, children)
|
||||||
if self.registryValue('cpu.threads', target):
|
if self.registryValue('cpu.threads', target):
|
||||||
spawned = utils.str.nItems('thread', world.threadsSpawned)
|
response += format('I have spawned %n; I currently have %i still '
|
||||||
response += 'I have spawned %s; I currently have %s still ' \
|
'running.',
|
||||||
'running.' % (spawned, activeThreads)
|
(world.threadsSpawned, 'thread'), activeThreads)
|
||||||
if self.registryValue('cpu.memory', target):
|
if self.registryValue('cpu.memory', target):
|
||||||
mem = 'an unknown amount'
|
mem = 'an unknown amount'
|
||||||
pid = os.getpid()
|
pid = os.getpid()
|
||||||
@ -179,10 +171,10 @@ class Status(callbacks.Privmsg):
|
|||||||
if cb.isCommand(attr) and \
|
if cb.isCommand(attr) and \
|
||||||
attr == callbacks.canonicalName(attr):
|
attr == callbacks.canonicalName(attr):
|
||||||
commands += 1
|
commands += 1
|
||||||
s = 'I offer a total of %s in %s. I have processed %s.' % \
|
s = format('I offer a total of %n in %n. I have processed %n.',
|
||||||
(utils.str.nItems('command', commands),
|
(commands, 'command'),
|
||||||
utils.str.nItems('plugin', callbacksPrivmsg, 'command-based'),
|
(callbacksPrivmsg, 'command-based', 'plugin'),
|
||||||
utils.str.nItems('command', world.commandsProcessed))
|
(world.commandsProcessed, 'command'))
|
||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
cmd = wrap(cmd)
|
cmd = wrap(cmd)
|
||||||
|
|
||||||
@ -191,7 +183,7 @@ class Status(callbacks.Privmsg):
|
|||||||
|
|
||||||
Returns a list of the commands offered by the bot.
|
Returns a list of the commands offered by the bot.
|
||||||
"""
|
"""
|
||||||
commands = sets.Set()
|
commands = set()
|
||||||
for cb in irc.callbacks:
|
for cb in irc.callbacks:
|
||||||
if isinstance(cb, callbacks.Privmsg) and \
|
if isinstance(cb, callbacks.Privmsg) and \
|
||||||
not isinstance(cb, callbacks.PrivmsgRegexp) and cb.public:
|
not isinstance(cb, callbacks.PrivmsgRegexp) and cb.public:
|
||||||
|
@ -39,7 +39,7 @@ import supybot.callbacks as callbacks
|
|||||||
|
|
||||||
class User(callbacks.Privmsg):
|
class User(callbacks.Privmsg):
|
||||||
def _checkNotChannel(self, irc, msg, password=' '):
|
def _checkNotChannel(self, irc, msg, password=' '):
|
||||||
if password and ircutils.isChannel(msg.args[0]):
|
if password and irc.isChannel(msg.args[0]):
|
||||||
raise callbacks.Error, conf.supybot.replies.requiresPrivacy()
|
raise callbacks.Error, conf.supybot.replies.requiresPrivacy()
|
||||||
|
|
||||||
def list(self, irc, msg, args, optlist, glob):
|
def list(self, irc, msg, args, optlist, glob):
|
||||||
@ -411,11 +411,11 @@ class User(callbacks.Privmsg):
|
|||||||
admins += 1
|
admins += 1
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
irc.reply('I have %s registered users '
|
irc.reply(format('I have %s registered users '
|
||||||
'with %s registered hostmasks; '
|
'with %s registered hostmasks; '
|
||||||
'%s and %s.' % (users, hostmasks,
|
'%n and %n.',
|
||||||
utils.str.nItems('owner', owners),
|
users, hostmasks,
|
||||||
utils.str.nItems('admin', admins)))
|
(owners, 'owner'), (admins, 'admin')))
|
||||||
stats = wrap(stats)
|
stats = wrap(stats)
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,11 +29,8 @@
|
|||||||
|
|
||||||
import types
|
import types
|
||||||
import random
|
import random
|
||||||
import string
|
|
||||||
|
|
||||||
import supybot.utils as utils
|
|
||||||
from supybot.commands import *
|
from supybot.commands import *
|
||||||
import supybot.ircmsgs as ircmsgs
|
|
||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user