mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 02:49:27 +01:00
fix docstring for Plugin.plugin command so it actually says what the command will do.
also add a Plugin.plugins command, which always returns a list of all plugins containing a command. add a test for it.
This commit is contained in:
parent
92fc1e308f
commit
7505f839fc
@ -72,7 +72,10 @@ class Plugin(callbacks.Plugin):
|
||||
def plugin(self, irc, msg, args, command):
|
||||
"""<command>
|
||||
|
||||
Returns the plugin(s) that <command> is in.
|
||||
Returns the name of the plugin that would be used to call <command>.
|
||||
|
||||
If it is not uniquely determined, returns list of all plugins that
|
||||
contain <command>.
|
||||
"""
|
||||
(maxL, cbs) = irc.findCallbacksForArgs(command)
|
||||
L = []
|
||||
@ -94,7 +97,40 @@ class Plugin(callbacks.Plugin):
|
||||
irc.error(format(_('There is no command %q.'), command))
|
||||
plugin = wrap(plugin, [many('something')])
|
||||
|
||||
def _findCallbacks(self, irc, command):
|
||||
command = map(callbacks.canonicalName, command)
|
||||
plugin_list = []
|
||||
for cb in irc.callbacks:
|
||||
if not hasattr(cb, 'getCommand'):
|
||||
continue
|
||||
commandlist = cb.getCommand(command)
|
||||
if commandlist:
|
||||
plugin_list.append(cb.name())
|
||||
return plugin_list
|
||||
|
||||
@internationalizeDocstring
|
||||
def plugins(self, irc, msg, args, command):
|
||||
"""<command>
|
||||
|
||||
Returns the names of all plugins that contain <command>.
|
||||
"""
|
||||
L = self._findCallbacks(irc, command)
|
||||
command = callbacks.formatCommand(command)
|
||||
if L:
|
||||
if irc.nested:
|
||||
irc.reply(format('%L', L))
|
||||
else:
|
||||
if len(L) > 1:
|
||||
plugin = 'plugins'
|
||||
else:
|
||||
plugin = 'plugin'
|
||||
irc.reply(format('The %q command is available in the %L %s.',
|
||||
command, L, plugin))
|
||||
else:
|
||||
irc.error(format('There is no command %q.', command))
|
||||
plugins = wrap(plugins, [many('something')])
|
||||
|
||||
>>>>>>> 3005752... fix docstring for Plugin.plugin command so it actually says what the command will do.
|
||||
def author(self, irc, msg, args, cb):
|
||||
"""<plugin>
|
||||
|
||||
|
@ -30,11 +30,15 @@
|
||||
from supybot.test import *
|
||||
|
||||
class PluginTestCase(PluginTestCase):
|
||||
plugins = ('Plugin', 'Utilities')
|
||||
plugins = ('Plugin', 'Utilities', 'Admin', 'Format')
|
||||
def testPlugin(self):
|
||||
self.assertRegexp('plugin plugin', 'available.*Plugin plugin')
|
||||
self.assertResponse('echo [plugin plugin]', 'Plugin')
|
||||
|
||||
|
||||
def testPlugins(self):
|
||||
self.assertRegexp('plugins join', '(Format.*Admin|Admin.*Format)')
|
||||
self.assertRegexp('plugins plugin', 'Plugin')
|
||||
|
||||
def testList(self):
|
||||
self.assertRegexp('plugin list', 'Plugin.*Utilities')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user