Compare commits

..

No commits in common. "b902e152435dbac4b6b350e4561e418fd6215203" and "fecab8aca66268383915e3117a1d0533fbcf729a" have entirely different histories.

4 changed files with 13 additions and 32 deletions

View file

@ -1,9 +1,3 @@
## 1.2.0a25 (2025-05-14)
### Feat
- can launch UserDatas twice
## 1.2.0a24 (2025-05-12) ## 1.2.0a24 (2025-05-12)
### Fix ### Fix

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project] [project]
name = "rougail" name = "rougail"
version = "1.2.0a25" version = "1.2.0a24"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}] authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md" readme = "README.md"
description = "A consistency handling system that was initially designed in the configuration management" description = "A consistency handling system that was initially designed in the configuration management"

View file

@ -1 +1 @@
__version__ = "1.2.0a25" __version__ = "1.2.0a24"

View file

@ -41,30 +41,19 @@ class UserDatas:
def __init__(self, config) -> None: def __init__(self, config) -> None:
self.config = config self.config = config
def user_datas(self, def user_datas(self, user_datas: List[dict]):
user_datas: List[dict],
*,
return_values_not_error=False,
user_datas_type: str="user_datas",
):
self.values = {} self.values = {}
self.errors = [] self.errors = []
self.warnings = [] self.warnings = []
self.show_secrets = False self.show_secrets = False
if user_datas_type == "user_datas": self._populate_values(user_datas)
self._populate_values(user_datas)
else:
self.values = user_datas
self._auto_configure_dynamics() self._auto_configure_dynamics()
self._populate_config() self._populate_config()
if return_values_not_error: self._populate_error_warnings()
return self.values return {
else: "errors": self.errors,
self._populate_error_warnings() "warnings": self.warnings,
return { }
"errors": self.errors,
"warnings": self.warnings,
}
def _populate_values(self, user_datas): def _populate_values(self, user_datas):
for datas in user_datas: for datas in user_datas:
@ -226,7 +215,7 @@ class UserDatas:
try: try:
option.value.set(value) option.value.set(value)
option.information.set( option.information.set(
"loaded_from", _("loaded from {0}").format(self.values[path]["source"]) "loaded_from", _("loaded from {0}").format(options["source"])
) )
value_is_set = True value_is_set = True
# value is correctly set, remove variable to the set # value is correctly set, remove variable to the set
@ -298,16 +287,15 @@ class UserDatas:
) )
if option.isfollower(): if option.isfollower():
indexes = range(len(value)) indexes = range(len(value))
values = value
else: else:
indexes = [None] indexes = [None]
for index in indexes: for index in indexes:
try: try:
if option.isfollower(): if option.isfollower():
value = values[index] val = value[index]
if value is undefined or isinstance(value, CancelParam): if val is undefined or isinstance(val, CancelParam):
continue continue
self.config.option(path, index).value.set(value) self.config.option(path, index).value.set(val)
else: else:
option.value.set(value) option.value.set(value)
except PropertiesOptionError as err: except PropertiesOptionError as err:
@ -376,7 +364,6 @@ class UserDatas:
).format( ).format(
self._display_value(option, value), self._display_value(option, value),
option.description(with_quote=True), option.description(with_quote=True),
index,
err, err,
options["source"], options["source"],
) )