From 5e8ac671dafb83692ec6b0448cc99e77d13a03d8 Mon Sep 17 00:00:00 2001 From: capitaldata Date: Wed, 25 Apr 2012 15:54:19 +0200 Subject: [PATCH] add list-modules option in the command line interface ex: radioob> backends list-modules Signed-off-by: capitaldata Signed-off-by: Romain Bignon --- weboob/tools/application/repl.py | 37 ++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/weboob/tools/application/repl.py b/weboob/tools/application/repl.py index 3a99722f..cf2a1cf3 100644 --- a/weboob/tools/application/repl.py +++ b/weboob/tools/application/repl.py @@ -506,7 +506,7 @@ class ReplApplication(Cmd, ConsoleApplication): def complete_backends(self, text, line, begidx, endidx): choices = [] - commands = ['enable', 'disable', 'only', 'list', 'add', 'register', 'edit', 'remove'] + commands = ['enable', 'disable', 'only', 'list', 'add', 'register', 'edit', 'remove', 'list-modules'] available_backends_names = set(backend.name for backend in self.weboob.iter_backends()) enabled_backends_names = set(backend.name for backend in self.enabled_backends) @@ -537,14 +537,15 @@ class ReplApplication(Cmd, ConsoleApplication): Select used backends. ACTION is one of the following (default: list): - * enable enable given backends - * disable disable given backends - * only enable given backends and disable the others - * list display enabled and available backends - * add add a backend - * register register a new account on a website - * edit edit a backend - * remove remove a backend + * enable enable given backends + * disable disable given backends + * only enable given backends and disable the others + * list list backends + * add add a backend + * register register a new account on a website + * edit edit a backend + * remove remove a backend + * list-modules list modules """ line = line.strip() if line: @@ -618,6 +619,24 @@ class ReplApplication(Cmd, ConsoleApplication): for backend in given_backends: self.weboob.backends_config.remove_backend(backend.name) self.unload_backends(backend.name) + elif action == 'list-modules': + modules = [] + print 'Modules list:' + for name, info in sorted(self.weboob.repositories.get_all_modules_info().iteritems()): + if not self.is_module_loadable(info): + continue + modules.append(name) + loaded = ' ' + for bi in self.weboob.iter_backends(): + if bi.NAME == name: + if loaded == ' ': + loaded = 'X' + elif loaded == 'X': + loaded = 2 + else: + loaded += 1 + print '[%s] %s%-15s%s %s' % (loaded, self.BOLD, name, self.NC, info.description) + else: print >>sys.stderr, 'Unknown action: "%s"' % action return 1