config get: Also inject ask strings in full mode

This commit is contained in:
Alexandre Aubin 2021-09-16 17:49:58 +02:00
parent 217ae87bb3
commit 96b112ac7f

View file

@ -65,10 +65,6 @@ class ConfigPanel:
self._load_current_values() self._load_current_values()
self._hydrate() self._hydrate()
# Format result in full mode
if mode == "full":
return self.config
# In 'classic' mode, we display the current value if key refer to an option # In 'classic' mode, we display the current value if key refer to an option
if self.filter_key.count(".") == 2 and mode == "classic": if self.filter_key.count(".") == 2 and mode == "classic":
option = self.filter_key.split(".")[-1] option = self.filter_key.split(".")[-1]
@ -81,13 +77,19 @@ class ConfigPanel:
key = f"{panel['id']}.{section['id']}.{option['id']}" key = f"{panel['id']}.{section['id']}.{option['id']}"
if mode == "export": if mode == "export":
result[option["id"]] = option.get("current_value") result[option["id"]] = option.get("current_value")
else: continue
ask = None
if "ask" in option: if "ask" in option:
result[key] = {"ask": _value_for_locale(option["ask"])} ask = _value_for_locale(option["ask"])
elif "i18n" in self.config: elif "i18n" in self.config:
result[key] = { ask = m18n.n(self.config["i18n"] + "_" + option["id"])
"ask": m18n.n(self.config["i18n"] + "_" + option["id"])
} if mode == "full":
# edit self.config directly
option["ask"] = ask
else:
result[key] = {"ask": ask}
if "current_value" in option: if "current_value" in option:
question_class = ARGUMENTS_TYPE_PARSERS[ question_class = ARGUMENTS_TYPE_PARSERS[
option.get("type", "string") option.get("type", "string")
@ -96,6 +98,9 @@ class ConfigPanel:
option["current_value"], option option["current_value"], option
) )
if mode == "full":
return self.config
else:
return result return result
def set( def set(