Skip to content
Snippets Groups Projects
Commit 62d46bfc authored by David Hendriks's avatar David Hendriks
Browse files

added a help all super function that calls help_all first, and then loops over...

added a help all super function that calls help_all first, and then loops over the parametr names to get more information
parent d71fc8b0
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,53 @@ from binarycpython.utils.custom_logging_functions import ( ...@@ -7,6 +7,53 @@ from binarycpython.utils.custom_logging_functions import (
create_and_load_logging_function, create_and_load_logging_function,
) )
def get_help_super(print_help=False, return_dict=True):
"""
Function that first runs get_help_all, and then per argument also run the help function to get as much information as possible.
"""
help_all_dict = get_help_all(print_help=False, return_dict=True)
# print(help_all_dict)
# print(json.dumps(help_all_dict, indent=4))
help_all_super_dict = help_all_dict.copy()
for section_name in help_all_dict.keys():
section = help_all_dict[section_name]
# print(section)
for parameter_name in section['parameters'].keys():
parameter = section['parameters'][parameter_name]
detailed_help = get_help(parameter_name, print_help=False, return_dict=True, fail_silently=True)
parameter['detailed_help'] = detailed_help
if parameter['detailed_help']:
if not parameter['description']==parameter['detailed_help']['description']:
print(json.dumps(parameter, indent=4))
# print(parameter['description']==parameter['detailed_help']['description'])
# print(parameter.keys())
if print_help:
print(json.dumps(help_all_super_dict, indent=4))
pass
if return_dict:
return
def get_help_all(print_help=True, return_dict=False): def get_help_all(print_help=True, return_dict=False):
""" """
...@@ -163,7 +210,7 @@ def get_arg_keys(): ...@@ -163,7 +210,7 @@ def get_arg_keys():
return get_defaults().keys() return get_defaults().keys()
def get_help(param_name, print_help=True, return_dict=False): def get_help(param_name, print_help=True, return_dict=False, fail_silently=False):
""" """
Function that returns the help info for a given parameter. Function that returns the help info for a given parameter.
...@@ -245,11 +292,12 @@ def get_help(param_name, print_help=True, return_dict=False): ...@@ -245,11 +292,12 @@ def get_help(param_name, print_help=True, return_dict=False):
return help_info_dict return help_info_dict
else: else:
print( if not fail_silently:
"{} is not a valid parameter name. Please choose from the following parameters:\n\t{}".format( print(
param_name, list(available_arg_keys) "{} is not a valid parameter name. Please choose from the following parameters:\n\t{}".format(
param_name, list(available_arg_keys)
)
) )
)
return None return None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment