From 5175ebca19a6c2bf8b0e5cb5bc22a73849e2fdc6 Mon Sep 17 00:00:00 2001 From: gwen Date: Mon, 9 Sep 2024 14:55:37 +0200 Subject: [PATCH] non string type multi variable ready for bash export --- src/rougail/user-data-environment/data.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/rougail/user-data-environment/data.py b/src/rougail/user-data-environment/data.py index c50e64e..5a166f8 100644 --- a/src/rougail/user-data-environment/data.py +++ b/src/rougail/user-data-environment/data.py @@ -88,20 +88,28 @@ class RougailUserDataEnvironment: default = option.value.get() ismulti = option.ismulti() type_obj = None + # here we retrieve the conversion func of the considered type + # carefull, it could be None -> in this case, do nothing type_obj = CONVERT_OPTION.get(option_type, {}).get("func") - -# print(CONVERT_OPTION) - + # rougail_environment_var = get_rougail_environment_var() option_name = option.path() if option_name in rougail_environment_var: - if ismulti: - pass + if ismulti: option_bash_value = get_rougail_environment_dict()[option_name] + # here we expect the bash option value of a multi to be coma separated: option_value = option_bash_value.split(",") - option.value.set(option_value) + if type_obj is not None: + option_value_typed = [type_obj(opt) for opt in option_value] + option.value.set(option_value_typed) + else: + option.value.set(option_value) else: - option.value.set(get_rougail_environment_dict()[option_name]) + option_bash_value = get_rougail_environment_dict()[option_name] + if type_obj is not None: + option.value.set(type_obj(option_bash_value)) + else: + option.value.set(option_bash_value) #RougailValidator.option = option #RougailValidator.option_type = {'type': option_type,