From d34f4a16fead4a2070bc9940f8313c9dee460c1f Mon Sep 17 00:00:00 2001 From: gwen Date: Tue, 10 Sep 2024 15:35:00 +0200 Subject: [PATCH] warnings ok --- src/rougail/user-data-environment/data.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/rougail/user-data-environment/data.py b/src/rougail/user-data-environment/data.py index 9c3e16f..53dc163 100644 --- a/src/rougail/user-data-environment/data.py +++ b/src/rougail/user-data-environment/data.py @@ -50,17 +50,18 @@ class RougailUserDataEnvironment: else: self.errors = [] self.warnings = [] + # bash environment variables (key/value pairs) + self.rougail_environment_vars = get_rougail_environment() def run(self): self.config.property.read_write() self.parse(self.config) self.config.property.read_only() - # about unused ROUGAIL_ environment variables - # FIXME -# if len(self.rougail_environment_vars): -# unused_env_var_str = " ".join(self.rougail_environment_vars.keys()) -# self.warnings.append("the following rougail environment variables " -# "are not used : " + unused_env_var_str) + # about unused bash environment variables + if len(self.rougail_environment_vars): + unused_env_var_str = ", ".join(self.rougail_environment_vars.keys()) + self.warnings.append("the following rougail bash environment " + "variable(s) are not used : " + unused_env_var_str) def parse(self, config): for option in config: @@ -78,9 +79,8 @@ class RougailUserDataEnvironment: option_name = option.path() # the bash variable are in upper case option_name = option_name.upper() - rougail_environment_vars = get_rougail_environment() # if the option is not in the bash environment, do nothing - if option_name not in rougail_environment_vars.keys(): + if option_name not in self.rougail_environment_vars.keys(): return # actually the rougail type **is not** the same thing as # the tiramisu type, which is in `option.type` @@ -90,11 +90,7 @@ class RougailUserDataEnvironment: # carefull, the coercion function 'func' could be None # -> in this case, do nothing type_obj = CONVERT_OPTION.get(option_type, {}).get("func") - option_bash_value = rougail_environment_vars.pop(option_name) - print("--------------") - print(option_name) - print(option_bash_value) - print(rougail_environment_vars) + option_bash_value = self.rougail_environment_vars.pop(option_name) if ismulti: # here we expect the bash option value of a multi to be coma separated: option_bash_value = [opt.strip() for opt in option_bash_value.split(",")]