From 0c03c1c48bb63d0b57adbd500aaabf0d1dfbdabf Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sat, 24 Mar 2018 08:04:00 +0100 Subject: [PATCH] [core/config] Skip unavailable modules If a module cannot be loaded (presumably, because some python modules are missing), do not show them in the list of available modules. fixes #237 --- bumblebee/config.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bumblebee/config.py b/bumblebee/config.py index 69dae84..9207c77 100644 --- a/bumblebee/config.py +++ b/bumblebee/config.py @@ -35,12 +35,15 @@ class print_usage(argparse.Action): def print_modules(self): for m in bumblebee.engine.all_modules(): - mod = importlib.import_module("bumblebee.modules.{}".format(m["name"])) - print(textwrap.fill("{}:".format(m["name"]), 80, - initial_indent=self._indent*2, subsequent_indent=self._indent*2)) - for line in mod.__doc__.split("\n"): - print(textwrap.fill(line, 80, - initial_indent=self._indent*3, subsequent_indent=self._indent*6)) + try: + mod = importlib.import_module("bumblebee.modules.{}".format(m["name"])) + print(textwrap.fill("{}:".format(m["name"]), 80, + initial_indent=self._indent*2, subsequent_indent=self._indent*2)) + for line in mod.__doc__.split("\n"): + print(textwrap.fill(line, 80, + initial_indent=self._indent*3, subsequent_indent=self._indent*6)) + except: + pass def create_parser(): """Create the argument parser"""