13from basf2.utils import print_all_modules, print_params
15from terminal_utils
import Pager
18def print_module_list(modName=None):
20 This wraps around the ``print_all_modules`` function but sanitizes potential command line arguments before doing so.
23 modName: Can be the name of a module or package. Prints more information about a specific module
or reduces the output
28 set_log_level(pybasf2.LogLevel.WARNING)
31 avModList = pybasf2.list_available_modules()
33 if modName
is not None:
35 if modName
in avModList:
37 current_module = pybasf2._register_module(modName)
38 with Pager(f
'Module information for "{modName}"', quit_if_one_screen=
True):
39 print_params(current_module,
False, avModList[modName])
40 except pybasf2.ModuleNotCreatedError:
41 pybasf2.B2FATAL(
'The module could not be loaded.')
42 except Exception
as e:
43 pybasf2.B2FATAL(f
"An exception occured when trying to create the module: {e}")
45 elif modName == modName.lower():
47 with Pager(f
'List of modules in package "{modName}"'):
48 print_all_modules(avModList, modName)
50 pybasf2.B2FATAL(
'Print module information: A module with the name "' +
51 modName +
'" does not exist!')
54 with Pager(
'List of all basf2 modules'):
55 print_all_modules(avModList)
58if __name__ ==
"__main__":
60 argument = sys.argv[1]
64 print_module_list(argument)