6 from basf2.utils import print_all_modules, print_params
8 from terminal_utils
import Pager
11 def print_module_list(modName=None):
13 This wraps around the ``print_all_modules`` function but sanitizes potential command line arguments before doing so.
16 modName: Can be the name of a module or package. Prints more information about a specific module or reduces the output
21 set_log_level(pybasf2.LogLevel.WARNING)
24 avModList = pybasf2.list_available_modules()
26 if modName
is not None:
28 if modName
in avModList:
30 current_module = pybasf2._register_module(modName)
31 with Pager(
'Module information for "%s"' % (modName), quit_if_one_screen=
True):
32 print_params(current_module,
False, avModList[modName])
33 except pybasf2.ModuleNotCreatedError:
34 pybasf2.B2FATAL(
'The module could not be loaded.')
35 except Exception
as e:
36 pybasf2.B2FATAL(
"An exception occured when trying to create the module: %s" % e)
38 elif modName == modName.lower():
40 with Pager(
'List of modules in package "%s"' % (modName)):
41 print_all_modules(avModList, modName)
43 pybasf2.B2FATAL(
'Print module information: A module with the name "' +
44 modName +
'" does not exist!')
47 with Pager(
'List of all basf2 modules'):
48 print_all_modules(avModList)
51 if __name__ ==
"__main__":
53 argument = sys.argv[1]
57 print_module_list(argument)