feat: can launch UserDatas twice
This commit is contained in:
parent
fecab8aca6
commit
cbccc8087f
1 changed files with 24 additions and 11 deletions
|
|
@ -41,19 +41,30 @@ class UserDatas:
|
|||
def __init__(self, config) -> None:
|
||||
self.config = config
|
||||
|
||||
def user_datas(self, user_datas: List[dict]):
|
||||
def user_datas(self,
|
||||
user_datas: List[dict],
|
||||
*,
|
||||
return_values_not_error=False,
|
||||
user_datas_type: str="user_datas",
|
||||
):
|
||||
self.values = {}
|
||||
self.errors = []
|
||||
self.warnings = []
|
||||
self.show_secrets = False
|
||||
self._populate_values(user_datas)
|
||||
if user_datas_type == "user_datas":
|
||||
self._populate_values(user_datas)
|
||||
else:
|
||||
self.values = user_datas
|
||||
self._auto_configure_dynamics()
|
||||
self._populate_config()
|
||||
self._populate_error_warnings()
|
||||
return {
|
||||
"errors": self.errors,
|
||||
"warnings": self.warnings,
|
||||
}
|
||||
if return_values_not_error:
|
||||
return self.values
|
||||
else:
|
||||
self._populate_error_warnings()
|
||||
return {
|
||||
"errors": self.errors,
|
||||
"warnings": self.warnings,
|
||||
}
|
||||
|
||||
def _populate_values(self, user_datas):
|
||||
for datas in user_datas:
|
||||
|
|
@ -215,7 +226,7 @@ class UserDatas:
|
|||
try:
|
||||
option.value.set(value)
|
||||
option.information.set(
|
||||
"loaded_from", _("loaded from {0}").format(options["source"])
|
||||
"loaded_from", _("loaded from {0}").format(self.values[path]["source"])
|
||||
)
|
||||
value_is_set = True
|
||||
# value is correctly set, remove variable to the set
|
||||
|
|
@ -287,15 +298,16 @@ class UserDatas:
|
|||
)
|
||||
if option.isfollower():
|
||||
indexes = range(len(value))
|
||||
values = value
|
||||
else:
|
||||
indexes = [None]
|
||||
for index in indexes:
|
||||
try:
|
||||
if option.isfollower():
|
||||
val = value[index]
|
||||
if val is undefined or isinstance(val, CancelParam):
|
||||
value = values[index]
|
||||
if value is undefined or isinstance(value, CancelParam):
|
||||
continue
|
||||
self.config.option(path, index).value.set(val)
|
||||
self.config.option(path, index).value.set(value)
|
||||
else:
|
||||
option.value.set(value)
|
||||
except PropertiesOptionError as err:
|
||||
|
|
@ -364,6 +376,7 @@ class UserDatas:
|
|||
).format(
|
||||
self._display_value(option, value),
|
||||
option.description(with_quote=True),
|
||||
index,
|
||||
err,
|
||||
options["source"],
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue