WIP: Expand the developer documentation #27

Draft
gremond wants to merge 189 commits from develop into developer_docs
Showing only changes of commit cbccc8087f - Show all commits

View file

@ -41,14 +41,25 @@ class UserDatas:
def __init__(self, config) -> None: def __init__(self, config) -> None:
self.config = config 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.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:
return self.values
else:
self._populate_error_warnings() self._populate_error_warnings()
return { return {
"errors": self.errors, "errors": self.errors,
@ -215,7 +226,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(options["source"]) "loaded_from", _("loaded from {0}").format(self.values[path]["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
@ -287,15 +298,16 @@ 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():
val = value[index] value = values[index]
if val is undefined or isinstance(val, CancelParam): if value is undefined or isinstance(value, CancelParam):
continue continue
self.config.option(path, index).value.set(val) self.config.option(path, index).value.set(value)
else: else:
option.value.set(value) option.value.set(value)
except PropertiesOptionError as err: except PropertiesOptionError as err:
@ -364,6 +376,7 @@ 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"],
) )