diff --git a/binarycpython/utils/functions.py b/binarycpython/utils/functions.py index 18371010a825d8a4e904a6d2533e0c4ce8891ff7..f1ef1fad56e0b7e54d37c801d9c85f5a559b6217 100644 --- a/binarycpython/utils/functions.py +++ b/binarycpython/utils/functions.py @@ -364,13 +364,29 @@ def get_help_all(print_help=True, return_dict=False): return None -def create_arg_string(arg_dict): +def create_arg_string(arg_dict, sort=False, filter_values=False): """ Function that creates the arg string + + Options: + sort: sort the order of the keys + filter_values: filters the input dict on keys that have NULL or `function` as value + """ arg_string = "" - for key in arg_dict.keys(): - arg_string += "{key} {value} ".format(key=key, value=arg_dict[key]) + + # + keys = sorted(arg_dict.keys()) if sort else arg_dict.keys() + + # + for key in keys: + # Filter out NULLS (not compiled anyway) + if filter_values: + if not value in ["NULL", "Function"]: + if not value == "": + default_dict[key] = value + else: + arg_string += "{key} {value} ".format(key=key, value=arg_dict[key]) arg_string = arg_string.strip() return arg_string