From f2e403a16b51caacf1228bac2d243c5872ad2028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Natal=20Ng=C3=A9tal?= Date: Tue, 20 Aug 2019 09:29:05 +0200 Subject: [PATCH] Use python docstring. Use the python docstring format for the documentation of the function. Add the documentation for the parameter and raise error. Remove the unless variable. Change-Id: I83353eaa6f927b62b9840daeb2b8c0a1c836acfa --- tripleoclient/utils.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index 6c41ced47..b65611078 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -1814,7 +1814,7 @@ def get_validations_parameters(validations_data, def get_validations_table(validations_data): - """Return the validations information as a pretty printed table """ + """Return the validations information as a pretty printed table""" param_field_name = get_param_field_name(validations_data) t = PrettyTable(border=True, header=True, padding_width=1) @@ -1892,16 +1892,22 @@ def ansible_symlink(): def check_file_for_enabled_service(env_file): - # This function checks environment file for the said service. - # If stack to be deployed/updated/upgraded has any deprecated service - # enabled, throw a warning about its deprecation and ask the user - # whether to proceed with deployment despite deprecation. - # For ODL as an example: - # If "OS::TripleO::Services::OpenDaylightApi" service is included - # in any of the parsed env_files, then check its value. - # OS::TripleO::Services::OpenDaylightApi NOT OS::Heat::None - # ODL is enabled. + """Checks environment file for the said service. + If stack to be to be deployed/updated/upgraded has any deprecated service + enabled, throw a warning about its deprecation and ask the user + whether to proceed with deployment despite deprecation. + For ODL as an example: + If "OS::TripleO::Services::OpenDaylightApi" service is included + in any of the parsed env_files, then check its value. + OS::TripleO::Services::OpenDaylightApi NOT OS::Heat::None + ODL is enabled. + + :param env_file: The path of the environment file + :type env_file: String + + :raises CommandError: If the action is not confirmed + """ if os.path.exists(env_file): with open(env_file, "r") as f: content = yaml.load(f) @@ -1913,7 +1919,7 @@ def check_file_for_enabled_service(env_file): + str(env_file) + ". " + constants.DEPRECATED_SERVICES[service]) deprecated_services_enabled.append(service) - except (KeyError, TypeError) as e: + except (KeyError, TypeError): # ignore if content["resource_registry"] is empty pass if deprecated_services_enabled: