From 53b26d2eb7ef0c6d1c17d3b9c8ff98afdfdb0a7d Mon Sep 17 00:00:00 2001 From: urlbot Date: Thu, 2 Jul 2015 14:26:23 +0200 Subject: [PATCH] add 'list' plugin listing command and parser states --- plugins.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/plugins.py b/plugins.py index a3c0a67..bf75400 100644 --- a/plugins.py +++ b/plugins.py @@ -734,6 +734,44 @@ def command_show_moinlist(argv, **args): ) } +@pluginfunction('list', 'list plugin and parser status', ptypes_COMMAND) +def command_list(argv, **args): + if 'list' != argv[0]: + return + + log.plugin('list plugin called') + + if 'enabled' in argv and 'disabled' in argv: + return { + 'msg': args['reply_user'] + ": both 'enabled' and 'disabled' makes no sense" + } + + # if not given, asume both + if not 'command' in argv and not 'parser' in argv: + argv.append('command') + argv.append('parser') + + out_command = [] + out_parser = [] + if 'command' in argv: + out_command = plugins[ptypes_COMMAND] + if 'parser' in argv: + out_parser = plugins[ptypes_PARSE] + if 'enabled' in argv: + out_command = [p for p in out_command if p.is_enabled] + out_parser = [p for p in out_parser if p.is_enabled] + if 'disabled' in argv: + out_command = [p for p in out_command if not p.is_enabled] + out_parser = [p for p in out_parser if not p.is_enabled] + + msg = [args['reply_user'] + ': list of plugins:'] + + if out_command: + msg.append('commands: %s' % ', '.join([p.plugin_name for p in out_command])) + if out_parser: + msg.append('parsers: %s' % ', '.join([p.plugin_name for p in out_parser])) + return {'msg': msg} + #@pluginfunction('dummy', 'dummy description', ptypes_COMMAND) #def command_dummy(argv, **args): # if 'dummy' != argv[0]: