def print_module_list(args): load_modules() scanner = Scanner() mod_mgr = scanner.get_module_manager() modules = mod_mgr.get_modules(base_class=args.base_class) modules.sort(key=lambda m: m.name) for module in modules: name = module.name text = module.__doc__ if text is None: text = "" text = text.splitlines() while len(text) > 0: if len(text[0].strip()) > 0: break text.pop(0) if len(text) == 0: text = "" else: text = text[0] text = textwrap.dedent(text) (status_color, status_icon) = console.map_module_status(module.status) print("{0}({3}{2}{4}) - {1}".format(name, text, status_icon, status_color, console.color.RESET)) return 0
def print_module_list(args): load_modules() scanner = Scanner() mod_mgr = scanner.get_module_manager() modules = mod_mgr.get_modules(base_class=args.base_class) for module in modules: name = module.name text = module.__doc__ if text is None: text = "" text = text.splitlines() while len(text) > 0: if len(text[0].strip()) > 0: break text.pop(0) if len(text) == 0: text = "" else: text = text[0] text = textwrap.dedent(text) print("{0} - {1}".format(name, text)) return 0
def print_module_list(args): load_modules() scanner = Scanner() mod_mgr = scanner.get_module_manager() modules = mod_mgr.get_modules(base_class=args.base_class) modules.sort(key=lambda m: m.name) for module in modules: name = module.name text = module.__doc__ if text is None: text = "" text = text.splitlines() while len(text) > 0: if len(text[0].strip()) > 0: break text.pop(0) if len(text) == 0: text = "" else: text = text[0] text = textwrap.dedent(text) (status_color, status_icon) = console.map_module_status(module.status) print( "{0}({3}{2}{4}) - {1}".format( name, text, status_icon, status_color, console.color.RESET ) ) return 0
def print_module_info(args): load_modules() scanner = Scanner() mod_mgr = scanner.get_module_manager() modules = mod_mgr.get_modules(base_class=args.base_class) module_found = None for module in modules: if module.name == args.module_name: module_found = module if module_found is None: logger.error("Unable to display help. Module '{0}' not found.".format( args.module_name)) return 1 module = module_found(scanner=scanner) heading = "Module: {}".format(args.module_name) print("") print(heading) print("=" * len(heading)) print("") if module.alias and len(module.alias) > 0: print("Alias:") print("") for alias in module.alias: print("* {}".format(alias)) print("") print("Status: {}".format(STATUS_NAMES.get(module.status, "Unknown"))) print("") if module.status_messages: for msg in module.status_messages: print("* {}".format(msg)) print("") text = module.__doc__ if text is None: text = "" text = textwrap.dedent(text) text = text.lstrip("\n") print(textwrap.fill(text, width=80)) print("") for name in module.config.get_option_names(): option = module.config.get_option(name) text = option.help if text is None or text.strip() == "": text = "No help text available" indent_text = "{0} - ".format(option.name) indent_len = len(indent_text) print(textwrap.fill(text, initial_indent=indent_text)) print("{}Type: {}".format(" " * indent_len, option.type)) print("{}Default: {}".format(" " * indent_len, option.default)) values = option.values if values is not None: if callable(values): values = values(option) print( textwrap.fill("Values: {0}".format(", ".join(values)), initial_indent=" " * indent_len, subsequent_indent=" " * indent_len)) print("") return 0
def print_module_info(args): load_modules() scanner = Scanner() mod_mgr = scanner.get_module_manager() modules = mod_mgr.get_modules(base_class=args.base_class) module_found = None for module in modules: if module.name == args.module_name: module_found = module if module_found is None: logger.error( "Unable to display help. Module '{0}' not found.".format( args.module_name ) ) return 1 module = module_found(scanner=scanner) heading = "Module: {}".format(args.module_name) print("") print(heading) print("="*len(heading)) print("") text = module.__doc__ if text is None: text = "" text = textwrap.dedent(text) text = text.lstrip("\n") print(textwrap.fill(text, width=80)) print("") for name in module.config.get_option_names(): option = module.config.get_option(name) text = option.help if text is None or text.strip() == "": text = "No help text available" indent_text = "{0} - ".format( option.name ) indent_len = len(indent_text) print( textwrap.fill( text, initial_indent=indent_text ) ) print( "{}Type: {}".format( " "*indent_len, option.type ) ) print( "{}Default: {}".format( " "*indent_len, option.default ) ) values = option.values if values is not None: if callable(values): values = values(option) print( textwrap.fill( "Values: {0}".format( ", ".join(values) ), initial_indent=" "*indent_len, subsequent_indent=" "*indent_len ) ) print("") return 0