diff --git a/software-client/software_client/common/utils.py b/software-client/software_client/common/utils.py index 43217908..9bfeebe5 100644 --- a/software-client/software_client/common/utils.py +++ b/software-client/software_client/common/utils.py @@ -157,6 +157,18 @@ def _display_error(status_code, text): print(HTTP_ERRORS[status_code]) +def format_data(data, header, format_func): + """ + Format data applying a formatting function to all values under specified header + :param data: list of dict with the data + :param header: string with the header of the data that must be formatted + :param format_func: function to be applied to change the value + """ + for d in data: + if header in d: + d[header] = format_func(d[header]) + + def display_info(resp): ''' This function displays basic REST API return, w/ info json object: diff --git a/software-client/software_client/v1/deploy_shell.py b/software-client/software_client/v1/deploy_shell.py index 022a3201..48cf4046 100644 --- a/software-client/software_client/v1/deploy_shell.py +++ b/software-client/software_client/v1/deploy_shell.py @@ -34,6 +34,7 @@ def do_show(cc, args): "To Release": "to_release", "RR": "reboot_required", "State": "state"} + utils.format_data(data, header="state", format_func=lambda x: f"deploy-{x}") utils.display_result_list(header_data_list, data) else: utils.display_info(resp)