diff --git a/binarycpython/utils/functions.py b/binarycpython/utils/functions.py index fa525601be2710abc0f02b85a64ab047ec76ffb1..756401682cb877a98471d1aaa53052a92f194a1a 100644 --- a/binarycpython/utils/functions.py +++ b/binarycpython/utils/functions.py @@ -7,6 +7,53 @@ from binarycpython.utils.custom_logging_functions import ( 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): """ @@ -163,7 +210,7 @@ def get_arg_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. @@ -245,11 +292,12 @@ def get_help(param_name, print_help=True, return_dict=False): return help_info_dict else: - print( - "{} is not a valid parameter name. Please choose from the following parameters:\n\t{}".format( - param_name, list(available_arg_keys) + if not fail_silently: + print( + "{} is not a valid parameter name. Please choose from the following parameters:\n\t{}".format( + param_name, list(available_arg_keys) + ) ) - ) return None