WIP: Expand the developer documentation #27
23 changed files with 204 additions and 90 deletions
|
|
@ -53,31 +53,52 @@ class Annotator(Walk):
|
||||||
self.objectspace = objectspace
|
self.objectspace = objectspace
|
||||||
self.frozen = {}
|
self.frozen = {}
|
||||||
if self.objectspace.paths:
|
if self.objectspace.paths:
|
||||||
|
self.convert_leadership()
|
||||||
self.convert_family()
|
self.convert_family()
|
||||||
self.convert_variable()
|
self.convert_variable()
|
||||||
|
|
||||||
|
def convert_leadership(self) -> None:
|
||||||
|
for variable_path in self.objectspace.leaders:
|
||||||
|
variable = self.objectspace.paths[variable_path]
|
||||||
|
if variable.hidden:
|
||||||
|
family = self.objectspace.paths[variable.path.rsplit(".", 1)[0]]
|
||||||
|
hidden = variable.hidden
|
||||||
|
if hidden is not True:
|
||||||
|
hidden = hidden.model_copy()
|
||||||
|
if hidden.ori_path is None:
|
||||||
|
hidden.ori_path = variable_path
|
||||||
|
family.hidden = hidden
|
||||||
|
variable.hidden = None
|
||||||
|
|
||||||
def convert_family(self) -> None:
|
def convert_family(self) -> None:
|
||||||
"""convert families"""
|
"""convert families"""
|
||||||
for family in self.get_families():
|
for family in self.get_families():
|
||||||
self._convert_property(family)
|
self._convert_property(family)
|
||||||
# collect for force_default_on_freeze
|
# collect for force_default_on_freeze
|
||||||
if family.hidden:
|
if family.hidden:
|
||||||
|
if family.hidden is True:
|
||||||
|
frozen = True
|
||||||
|
else:
|
||||||
|
frozen = family.hidden.model_copy()
|
||||||
|
frozen.attribute_name = "frozen"
|
||||||
|
if frozen.ori_path is None:
|
||||||
|
frozen.ori_path = family.path
|
||||||
self.set_variable_frozen(
|
self.set_variable_frozen(
|
||||||
family.path,
|
family.path,
|
||||||
family.hidden,
|
frozen,
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_variable_frozen(
|
def set_variable_frozen(
|
||||||
self,
|
self,
|
||||||
family_path: str,
|
family_path: str,
|
||||||
hidden: Union[bool, Calculation],
|
frozen: Union[bool, Calculation],
|
||||||
) -> None:
|
) -> None:
|
||||||
for variable_path in self.objectspace.parents[family_path]:
|
for variable_path in self.objectspace.parents[family_path]:
|
||||||
if variable_path in self.objectspace.families:
|
if variable_path in self.objectspace.families:
|
||||||
# it's a family
|
# it's a family
|
||||||
self.set_variable_frozen(
|
self.set_variable_frozen(
|
||||||
variable_path,
|
variable_path,
|
||||||
hidden,
|
frozen,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# it's a variable
|
# it's a variable
|
||||||
|
|
@ -86,13 +107,16 @@ class Annotator(Walk):
|
||||||
if (
|
if (
|
||||||
self.frozen.get(variable.path) is True
|
self.frozen.get(variable.path) is True
|
||||||
or variable.hidden is True
|
or variable.hidden is True
|
||||||
or hidden is True
|
or frozen is True
|
||||||
):
|
):
|
||||||
self.frozen[variable.path] = True
|
self.frozen[variable.path] = True
|
||||||
elif variable.path in self.frozen:
|
|
||||||
self.frozen[variable.path].append(hidden)
|
|
||||||
else:
|
else:
|
||||||
self.frozen[variable.path] = [hidden]
|
if variable.path in self.frozen:
|
||||||
|
if not isinstance(self.frozen[variable.path], list):
|
||||||
|
self.frozen[variable.path] = [frozen]
|
||||||
|
self.frozen[variable.path].append(frozen)
|
||||||
|
else:
|
||||||
|
self.frozen[variable.path] = frozen
|
||||||
|
|
||||||
def convert_variable(self) -> None:
|
def convert_variable(self) -> None:
|
||||||
"""convert variables"""
|
"""convert variables"""
|
||||||
|
|
@ -114,22 +138,18 @@ class Annotator(Walk):
|
||||||
if variable.hidden is True:
|
if variable.hidden is True:
|
||||||
self.frozen[path] = True
|
self.frozen[path] = True
|
||||||
elif self.frozen.get(path) is not True:
|
elif self.frozen.get(path) is not True:
|
||||||
self.frozen.setdefault(path, []).append(variable.hidden)
|
frozen = variable.hidden.model_copy()
|
||||||
|
frozen.attribute_name = "frozen"
|
||||||
|
if frozen.ori_path is None:
|
||||||
|
frozen.ori_path = path
|
||||||
if path in self.frozen:
|
if path in self.frozen:
|
||||||
frozen = self.frozen[path]
|
if not isinstance(self.frozen, list):
|
||||||
if frozen is True:
|
self.frozen[path] = [self.frozen[path]]
|
||||||
value = True
|
self.frozen[path].append(frozen)
|
||||||
else:
|
else:
|
||||||
value = []
|
self.frozen[path] = frozen
|
||||||
for calculation in frozen:
|
if path in self.frozen:
|
||||||
calculation_copy = calculation.model_copy()
|
self.objectspace.properties.add(path, "frozen", self.frozen[path])
|
||||||
calculation_copy.attribute_name = "frozen"
|
|
||||||
# calculation_copy.ori_path = calculation_copy.path
|
|
||||||
# calculation_copy.path = path
|
|
||||||
value.append(calculation_copy)
|
|
||||||
if len(value) == 1:
|
|
||||||
value = value[0]
|
|
||||||
self.objectspace.properties.add(path, "frozen", value)
|
|
||||||
if not variable.auto_save:
|
if not variable.auto_save:
|
||||||
# if auto_save, save calculated value
|
# if auto_save, save calculated value
|
||||||
self.objectspace.properties.add(path, "force_default_on_freeze", True)
|
self.objectspace.properties.add(path, "force_default_on_freeze", True)
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,6 @@ class Walk:
|
||||||
for path in self.objectspace.variables:
|
for path in self.objectspace.variables:
|
||||||
yield self.objectspace.paths[path]
|
yield self.objectspace.paths[path]
|
||||||
|
|
||||||
# yield from get_variables(self.objectspace)
|
|
||||||
|
|
||||||
def get_families(self):
|
def get_families(self):
|
||||||
"""Iter all families from the objectspace"""
|
"""Iter all families from the objectspace"""
|
||||||
for path in self.objectspace.families:
|
for path in self.objectspace.families:
|
||||||
|
|
@ -178,7 +176,6 @@ class Annotator(Walk): # pylint: disable=R0903
|
||||||
|
|
||||||
variable.validators.append(
|
variable.validators.append(
|
||||||
JinjaCalculation(
|
JinjaCalculation(
|
||||||
path=variable.path,
|
|
||||||
inside_list=True,
|
inside_list=True,
|
||||||
version=variable.version,
|
version=variable.version,
|
||||||
xmlfiles=variable.xmlfiles,
|
xmlfiles=variable.xmlfiles,
|
||||||
|
|
@ -242,7 +239,7 @@ class Annotator(Walk): # pylint: disable=R0903
|
||||||
if calculated_variable.multi is None:
|
if calculated_variable.multi is None:
|
||||||
if (
|
if (
|
||||||
isinstance(calculated_variable.default, VariableCalculation)
|
isinstance(calculated_variable.default, VariableCalculation)
|
||||||
and variable.path == calculated_variable.default.variable
|
and variable.path == calculated_variable.path
|
||||||
):
|
):
|
||||||
msg = _(
|
msg = _(
|
||||||
'the "{0}" default value is a calculation with itself'
|
'the "{0}" default value is a calculation with itself'
|
||||||
|
|
@ -276,6 +273,12 @@ class Annotator(Walk): # pylint: disable=R0903
|
||||||
variable.params = calculated_variable.params
|
variable.params = calculated_variable.params
|
||||||
if variable.type == "choice" and variable.choices is None:
|
if variable.type == "choice" and variable.choices is None:
|
||||||
variable.choices = calculated_variable.choices
|
variable.choices = calculated_variable.choices
|
||||||
|
if isinstance(variable.choices, VariableCalculation):
|
||||||
|
variable.choices = variable.choices.model_copy()
|
||||||
|
variable.choices.variable = self.objectspace.paths.get_full_path(
|
||||||
|
variable.choices.variable,
|
||||||
|
calculated_variable.path,
|
||||||
|
)
|
||||||
if variable.type == "regexp" and variable.regexp is None:
|
if variable.type == "regexp" and variable.regexp is None:
|
||||||
variable.regexp = calculated_variable.regexp
|
variable.regexp = calculated_variable.regexp
|
||||||
|
|
||||||
|
|
@ -297,13 +300,6 @@ class Annotator(Walk): # pylint: disable=R0903
|
||||||
self.objectspace.multis[variable.path] = "submulti"
|
self.objectspace.multis[variable.path] = "submulti"
|
||||||
elif variable.multi:
|
elif variable.multi:
|
||||||
self.objectspace.multis[variable.path] = True
|
self.objectspace.multis[variable.path] = True
|
||||||
if variable.path in self.objectspace.leaders:
|
|
||||||
family = self.objectspace.paths[variable.path.rsplit(".", 1)[0]]
|
|
||||||
if variable.hidden:
|
|
||||||
family.hidden = variable.hidden
|
|
||||||
# elif family.hidden:
|
|
||||||
# variable.hidden = family.hidden
|
|
||||||
variable.hidden = None
|
|
||||||
if variable.regexp is not None and variable.type != "regexp":
|
if variable.regexp is not None and variable.type != "regexp":
|
||||||
msg = _(
|
msg = _(
|
||||||
'the variable "{0}" has regexp attribut but has not the "regexp" type'
|
'the variable "{0}" has regexp attribut but has not the "regexp" type'
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ class Calculation(BaseModel):
|
||||||
# path: str
|
# path: str
|
||||||
inside_list: bool
|
inside_list: bool
|
||||||
version: str
|
version: str
|
||||||
# ori_path: Optional[str] = None
|
ori_path: Optional[str] = None
|
||||||
default_values: Any = None
|
default_values: Any = None
|
||||||
namespace: Optional[str]
|
namespace: Optional[str]
|
||||||
warnings: Optional[bool] = None
|
warnings: Optional[bool] = None
|
||||||
|
|
@ -261,15 +261,11 @@ class Calculation(BaseModel):
|
||||||
def get_params(self, objectspace, path):
|
def get_params(self, objectspace, path):
|
||||||
if self.warnings is not None and self.attribute_name != "validators":
|
if self.warnings is not None and self.attribute_name != "validators":
|
||||||
msg = _(
|
msg = _(
|
||||||
'"warnings" are only available with attribute "{self.attribute_name}" for variable "{self.ori_path}"'
|
'"warnings" are only available with attribute "{self.attribute_name}" for variable "{self.path}"'
|
||||||
)
|
)
|
||||||
raise DictConsistencyError(msg, 83, xmlfiles)
|
raise DictConsistencyError(msg, 83, xmlfiles)
|
||||||
if not self.params:
|
if not self.params:
|
||||||
return {}
|
return {}
|
||||||
# if self.ori_path is None:
|
|
||||||
# path = self.path
|
|
||||||
# else:
|
|
||||||
# path = self.ori_path
|
|
||||||
params = {}
|
params = {}
|
||||||
for param_obj in self.params:
|
for param_obj in self.params:
|
||||||
param = param_obj.to_param(
|
param = param_obj.to_param(
|
||||||
|
|
@ -315,12 +311,15 @@ class JinjaCalculation(Calculation):
|
||||||
add_help=False,
|
add_help=False,
|
||||||
params: Optional[dict] = None,
|
params: Optional[dict] = None,
|
||||||
):
|
):
|
||||||
variable = objectspace.paths[path]
|
internal_variable = path
|
||||||
jinja_path = f"{self.attribute_name}_{path}"
|
jinja_path = f"{self.attribute_name}_{path}"
|
||||||
idx = 0
|
idx = 0
|
||||||
while jinja_path in objectspace.jinja:
|
while jinja_path in objectspace.jinja:
|
||||||
jinja_path = f"{self.attribute_name}_{path}_{idx}"
|
jinja_path = f"{self.attribute_name}_{path}_{idx}"
|
||||||
idx += 1
|
idx += 1
|
||||||
|
if self.ori_path is not None:
|
||||||
|
path = self.ori_path
|
||||||
|
variable = objectspace.paths[path]
|
||||||
objectspace.jinja[jinja_path] = self.jinja
|
objectspace.jinja[jinja_path] = self.jinja
|
||||||
if return_type in RENAME_TYPE:
|
if return_type in RENAME_TYPE:
|
||||||
warning = _('the variable "{0}" has a depreciated return_type "{1}", please use "{2}" instead in {3}')
|
warning = _('the variable "{0}" has a depreciated return_type "{1}", please use "{2}" instead in {3}')
|
||||||
|
|
@ -338,7 +337,7 @@ class JinjaCalculation(Calculation):
|
||||||
"__internal_multi": multi,
|
"__internal_multi": multi,
|
||||||
"__internal_files": self.xmlfiles,
|
"__internal_files": self.xmlfiles,
|
||||||
"__internal_attribute": self.attribute_name,
|
"__internal_attribute": self.attribute_name,
|
||||||
"__internal_variable": path,
|
"__internal_variable": internal_variable,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if self.default_values:
|
if self.default_values:
|
||||||
|
|
@ -349,10 +348,6 @@ class JinjaCalculation(Calculation):
|
||||||
default["params"] |= self.get_params(objectspace, path)
|
default["params"] |= self.get_params(objectspace, path)
|
||||||
if params:
|
if params:
|
||||||
default["params"] |= params
|
default["params"] |= params
|
||||||
# if self.ori_path is None:
|
|
||||||
# path = self.path
|
|
||||||
# else:
|
|
||||||
# path = self.ori_path
|
|
||||||
if self.warnings:
|
if self.warnings:
|
||||||
default["warnings_only"] = True
|
default["warnings_only"] = True
|
||||||
for sub_variable, identifier, true_path in get_jinja_variable_to_param(
|
for sub_variable, identifier, true_path in get_jinja_variable_to_param(
|
||||||
|
|
@ -389,6 +384,8 @@ class JinjaCalculation(Calculation):
|
||||||
path,
|
path,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
if self.attribute_name in ["default", "secret_manager"]:
|
if self.attribute_name in ["default", "secret_manager"]:
|
||||||
|
if self.ori_path is not None:
|
||||||
|
path = self.ori_path
|
||||||
if self.return_type:
|
if self.return_type:
|
||||||
raise Exception("return_type not allowed!")
|
raise Exception("return_type not allowed!")
|
||||||
variable = objectspace.paths[path]
|
variable = objectspace.paths[path]
|
||||||
|
|
@ -411,10 +408,8 @@ class JinjaCalculation(Calculation):
|
||||||
if return_type is None:
|
if return_type is None:
|
||||||
return_type = "string"
|
return_type = "string"
|
||||||
if return_type not in ["string", "boolean"]:
|
if return_type not in ["string", "boolean"]:
|
||||||
# if self.ori_path is None:
|
if self.ori_path is not None:
|
||||||
# path = path
|
path = self.ori_path
|
||||||
# else:
|
|
||||||
# path = self.ori_path
|
|
||||||
msg = _(
|
msg = _(
|
||||||
'variable "{0}" has a calculating "{1}" with an invalid return_type, should be boolean or string, not "{2}"'
|
'variable "{0}" has a calculating "{1}" with an invalid return_type, should be boolean or string, not "{2}"'
|
||||||
).format(path, self.attribute_name, return_type)
|
).format(path, self.attribute_name, return_type)
|
||||||
|
|
@ -422,9 +417,13 @@ class JinjaCalculation(Calculation):
|
||||||
if return_type == 'boolean':
|
if return_type == 'boolean':
|
||||||
description = self.description
|
description = self.description
|
||||||
if description is None:
|
if description is None:
|
||||||
|
if self.ori_path is not None:
|
||||||
|
opath = self.ori_path
|
||||||
|
else:
|
||||||
|
opath = path
|
||||||
warning = _('the variable "{0}" has a return_type "{1}", for attribute "{2}" but has not description in {3}')
|
warning = _('the variable "{0}" has a return_type "{1}", for attribute "{2}" but has not description in {3}')
|
||||||
warn(
|
warn(
|
||||||
warning.format(path, return_type, self.attribute_name, display_xmlfiles(self.xmlfiles)),
|
warning.format(opath, return_type, self.attribute_name, display_xmlfiles(self.xmlfiles)),
|
||||||
RougailWarning,
|
RougailWarning,
|
||||||
)
|
)
|
||||||
self.description = _('value is invalid')
|
self.description = _('value is invalid')
|
||||||
|
|
@ -443,10 +442,8 @@ class JinjaCalculation(Calculation):
|
||||||
if return_type is None:
|
if return_type is None:
|
||||||
return_type = "string"
|
return_type = "string"
|
||||||
if return_type not in ["string", "boolean"]:
|
if return_type not in ["string", "boolean"]:
|
||||||
# if self.ori_path is None:
|
if self.ori_path is not None:
|
||||||
# path = .path
|
path = self.ori_path
|
||||||
# else:
|
|
||||||
# path = self.ori_path
|
|
||||||
msg = _(
|
msg = _(
|
||||||
'variable "{0}" has a calculating "{1}" with an invalid return_type, should be boolean or string, not "{2}"'
|
'variable "{0}" has a calculating "{1}" with an invalid return_type, should be boolean or string, not "{2}"'
|
||||||
).format(path, self.attribute_name, return_type)
|
).format(path, self.attribute_name, return_type)
|
||||||
|
|
@ -501,10 +498,6 @@ class _VariableCalculation(Calculation):
|
||||||
objectspace,
|
objectspace,
|
||||||
path,
|
path,
|
||||||
) -> "Variable":
|
) -> "Variable":
|
||||||
# if self.ori_path is None:
|
|
||||||
# path = self.path
|
|
||||||
# else:
|
|
||||||
# path = self.ori_path
|
|
||||||
if self.version != "1.0" and objectspace.paths.regexp_relative.search(
|
if self.version != "1.0" and objectspace.paths.regexp_relative.search(
|
||||||
self.variable
|
self.variable
|
||||||
):
|
):
|
||||||
|
|
@ -549,10 +542,6 @@ class _VariableCalculation(Calculation):
|
||||||
):
|
):
|
||||||
if not variable_in_calculation:
|
if not variable_in_calculation:
|
||||||
if not objectspace.force_optional:
|
if not objectspace.force_optional:
|
||||||
# if self.ori_path is None:
|
|
||||||
# path = self.path
|
|
||||||
# else:
|
|
||||||
# path = self.ori_path
|
|
||||||
msg = _(
|
msg = _(
|
||||||
'variable "{0}" has an attribute "{1}" calculated with the unknown variable "{2}"'
|
'variable "{0}" has an attribute "{1}" calculated with the unknown variable "{2}"'
|
||||||
).format(path, self.attribute_name, self.variable)
|
).format(path, self.attribute_name, self.variable)
|
||||||
|
|
@ -589,10 +578,6 @@ class _VariableCalculation(Calculation):
|
||||||
def check_multi(
|
def check_multi(
|
||||||
self, objectspace, path, variable_in_calculation_path, variable_in_calculation
|
self, objectspace, path, variable_in_calculation_path, variable_in_calculation
|
||||||
):
|
):
|
||||||
# if self.ori_path is None:
|
|
||||||
# path = self.path
|
|
||||||
# else:
|
|
||||||
# path = self.ori_path
|
|
||||||
local_variable = objectspace.paths[path]
|
local_variable = objectspace.paths[path]
|
||||||
local_variable_multi, variable_in_calculation_multi = (
|
local_variable_multi, variable_in_calculation_multi = (
|
||||||
calc_multi_for_type_variable(
|
calc_multi_for_type_variable(
|
||||||
|
|
@ -742,6 +727,8 @@ class VariableCalculation(_VariableCalculation):
|
||||||
objectspace,
|
objectspace,
|
||||||
path,
|
path,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
|
if self.ori_path is not None:
|
||||||
|
path = self.ori_path
|
||||||
if (
|
if (
|
||||||
self.attribute_name != "default"
|
self.attribute_name != "default"
|
||||||
and self.optional
|
and self.optional
|
||||||
|
|
@ -760,7 +747,7 @@ class VariableCalculation(_VariableCalculation):
|
||||||
self.optional or objectspace.force_optional
|
self.optional or objectspace.force_optional
|
||||||
):
|
):
|
||||||
if self.default is not undefined:
|
if self.default is not undefined:
|
||||||
return self.get_default_value_optional(objectspace, self.default)
|
return self.get_default_value_optional(objectspace, path, self.default)
|
||||||
if self.default_values is not None:
|
if self.default_values is not None:
|
||||||
return self.default_values
|
return self.default_values
|
||||||
raise VariableCalculationDependencyError()
|
raise VariableCalculationDependencyError()
|
||||||
|
|
@ -798,6 +785,8 @@ class VariablePropertyCalculation(_VariableCalculation):
|
||||||
objectspace,
|
objectspace,
|
||||||
path,
|
path,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
|
if self.ori_path is not None:
|
||||||
|
path = self.ori_path
|
||||||
(
|
(
|
||||||
variable_in_calculation_path,
|
variable_in_calculation_path,
|
||||||
variable_in_calculation,
|
variable_in_calculation,
|
||||||
|
|
@ -818,7 +807,7 @@ class VariablePropertyCalculation(_VariableCalculation):
|
||||||
)
|
)
|
||||||
msg = msg.format(path, self.attribute_name, default)
|
msg = msg.format(path, self.attribute_name, default)
|
||||||
raise DictConsistencyError(msg, 79, self.xmlfiles)
|
raise DictConsistencyError(msg, 79, self.xmlfiles)
|
||||||
return self.get_default_value_optional(objectspace, default)
|
return self.get_default_value_optional(objectspace, path, default)
|
||||||
params = self.get_params(
|
params = self.get_params(
|
||||||
objectspace,
|
objectspace,
|
||||||
path,
|
path,
|
||||||
|
|
@ -887,6 +876,8 @@ class InformationCalculation(Calculation):
|
||||||
objectspace,
|
objectspace,
|
||||||
path,
|
path,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
|
if self.ori_path is not None:
|
||||||
|
path = self.ori_path
|
||||||
params = {
|
params = {
|
||||||
None: [
|
None: [
|
||||||
{
|
{
|
||||||
|
|
@ -896,10 +887,6 @@ class InformationCalculation(Calculation):
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
if self.variable:
|
if self.variable:
|
||||||
# if self.ori_path is None:
|
|
||||||
# path = self.path
|
|
||||||
# else:
|
|
||||||
# path = self.ori_path
|
|
||||||
variable, identifier = objectspace.paths.get_with_dynamic(
|
variable, identifier = objectspace.paths.get_with_dynamic(
|
||||||
self.variable,
|
self.variable,
|
||||||
path,
|
path,
|
||||||
|
|
@ -965,6 +952,7 @@ class IdentifierPropertyCalculation(_IdentifierCalculation):
|
||||||
def to_function(
|
def to_function(
|
||||||
self,
|
self,
|
||||||
objectspace,
|
objectspace,
|
||||||
|
path,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
if self.version == "1.0":
|
if self.version == "1.0":
|
||||||
msg = _(
|
msg = _(
|
||||||
|
|
|
||||||
|
|
@ -272,13 +272,6 @@ class UserData:
|
||||||
if path != option.path():
|
if path != option.path():
|
||||||
self.values[option.path()] = self.values.pop(values_path)
|
self.values[option.path()] = self.values.pop(values_path)
|
||||||
else:
|
else:
|
||||||
if "source" in self.values[values_path]:
|
|
||||||
option_without_index.information.set(
|
|
||||||
"loaded_from",
|
|
||||||
_("loaded from {0}").format(
|
|
||||||
self.values[values_path]["source"]
|
|
||||||
),
|
|
||||||
)
|
|
||||||
# value is correctly set, remove variable to the set
|
# value is correctly set, remove variable to the set
|
||||||
if index is not None:
|
if index is not None:
|
||||||
# if it's a follower waiting for all followers are sets
|
# if it's a follower waiting for all followers are sets
|
||||||
|
|
@ -401,7 +394,10 @@ class UserData:
|
||||||
if not isinstance(value, tuple):
|
if not isinstance(value, tuple):
|
||||||
indexes = range(len(value))
|
indexes = range(len(value))
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
indexes = range(len(option.parent().leader().value.get()))
|
indexes = range(len(option.parent().leader().value.get()))
|
||||||
|
except:
|
||||||
|
continue
|
||||||
values = value
|
values = value
|
||||||
else:
|
else:
|
||||||
indexes = [None]
|
indexes = [None]
|
||||||
|
|
@ -544,9 +540,11 @@ class UserData:
|
||||||
|
|
||||||
def set_value(self, option, value, options, index):
|
def set_value(self, option, value, options, index):
|
||||||
is_secret_manager = options.get("secret_manager", False)
|
is_secret_manager = options.get("secret_manager", False)
|
||||||
|
option_without_index = option
|
||||||
if is_secret_manager and isinstance(value, tuple):
|
if is_secret_manager and isinstance(value, tuple):
|
||||||
# it's a function
|
# it's a function
|
||||||
params = tuple([ParamValue(val) for val in value[1:]])
|
params = tuple([ParamValue(val) for val in value[1:]])
|
||||||
|
option.information.set('secret_manager', True)
|
||||||
if index is not None:
|
if index is not None:
|
||||||
option = option.forcepermissive.index(index)
|
option = option.forcepermissive.index(index)
|
||||||
value = Calculation(value[0], Params(params, kwargs={"option": ParamValue(option)}))
|
value = Calculation(value[0], Params(params, kwargs={"option": ParamValue(option)}))
|
||||||
|
|
@ -559,6 +557,25 @@ class UserData:
|
||||||
option.value.set(value)
|
option.value.set(value)
|
||||||
if add_validation:
|
if add_validation:
|
||||||
option.property.add("validator")
|
option.property.add("validator")
|
||||||
|
path = option.path()
|
||||||
|
if "source" in self.values[path]:
|
||||||
|
if option.isfollower():
|
||||||
|
key = f"loaded_from_{index}"
|
||||||
|
else:
|
||||||
|
key = "loaded_from"
|
||||||
|
value = _("loaded from {0}").format(
|
||||||
|
self.values[path]["source"]
|
||||||
|
)
|
||||||
|
if options.get("secret_manager"):
|
||||||
|
# FIXME (true_config ???)
|
||||||
|
default = option.value.default()
|
||||||
|
if option.isleader():
|
||||||
|
default = default[0]
|
||||||
|
value = _('{0} (the search key is "{1}")').format(value, default)
|
||||||
|
option_without_index.information.set(
|
||||||
|
key,
|
||||||
|
value,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def convert_value(option, value, needs_convert):
|
def convert_value(option, value, needs_convert):
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,6 @@ def get_jinja_variable_to_param(
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
unknown_variables.append(variable_path)
|
unknown_variables.append(variable_path)
|
||||||
|
|
||||||
for variable_path in unknown_variables:
|
for variable_path in unknown_variables:
|
||||||
for v in founded_variables:
|
for v in founded_variables:
|
||||||
if get_common_path(v, variable_path) == v:
|
if get_common_path(v, variable_path) == v:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from re import compile as re_compile
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('../rougail-tests/funcs/test.py')
|
||||||
|
try:
|
||||||
|
groups.namespace
|
||||||
|
except:
|
||||||
|
groups.addgroup('namespace')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_2 = BoolOption(name="condition", doc="a condition", default=True, properties=frozenset({"disabled", "mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_variable11/rougail/00-base.yml'], 'type': 'boolean'})
|
||||||
|
option_3 = StrOption(name="variable", doc="a variable", properties=frozenset({"basic", "mandatory", Calculation(func['variable_to_property'], Params((), kwargs={'value': ParamOption(option_2, raisepropertyerror=True), 'prop': ParamValue("disabled"), 'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property'])}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_variable11/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"basic"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from re import compile as re_compile
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('../rougail-tests/funcs/test.py')
|
||||||
|
try:
|
||||||
|
groups.namespace
|
||||||
|
except:
|
||||||
|
groups.addgroup('namespace')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_1 = BoolOption(name="condition", doc="a condition", default=True, properties=frozenset({"disabled", "mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_variable11/rougail/00-base.yml'], 'type': 'boolean'})
|
||||||
|
option_2 = StrOption(name="variable", doc="a variable", properties=frozenset({"basic", "mandatory", Calculation(func['variable_to_property'], Params((), kwargs={'value': ParamOption(option_1, raisepropertyerror=True), 'prop': ParamValue("disabled"), 'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property'])}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_variable11/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])
|
||||||
|
|
@ -12,10 +12,10 @@ ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
dict_env['frozen_rougail.leader.leader'] = "{% if __.condition == \"no\" %}\ncondition is no\n{% endif %}\n"
|
dict_env['frozen_rougail.leader.leader'] = "{% if __.condition == \"no\" %}\ncondition is no\n{% endif %}\n"
|
||||||
dict_env['frozen_rougail.leader.follower'] = "{% if __.condition == \"no\" %}\ncondition is no\n{% endif %}\n"
|
dict_env['frozen_rougail.leader.follower'] = "{% if __.condition == \"no\" %}\ncondition is no\n{% endif %}\n"
|
||||||
dict_env['hidden_rougail.leader.leader'] = "{% if __.condition == \"no\" %}\ncondition is no\n{% endif %}\n"
|
dict_env['hidden_rougail.leader'] = "{% if __.condition == \"no\" %}\ncondition is no\n{% endif %}\n"
|
||||||
option_2 = StrOption(name="condition", doc="a condition", default="no", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml'], 'type': 'string'})
|
option_2 = StrOption(name="condition", doc="a condition", default="no", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml'], 'type': 'string'})
|
||||||
option_4 = StrOption(name="leader", doc="a leader", multi=True, properties=frozenset({"force_default_on_freeze", "standard", Calculation(func['jinja_to_property'], Params((ParamValue("frozen"), ParamValue("if condition is no")), kwargs={'__internal_jinja': ParamValue("frozen_rougail.leader.leader"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']), '__internal_attribute': ParamValue("frozen"), '__internal_variable': ParamValue("rougail.leader.leader"), 'when': ParamValue(True), 'inverse': ParamValue(False), '__.condition': ParamOption(option_2, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml'], 'type': 'string'})
|
option_4 = StrOption(name="leader", doc="a leader", multi=True, properties=frozenset({"force_default_on_freeze", "standard", Calculation(func['jinja_to_property'], Params((ParamValue("frozen"), ParamValue("if condition is no")), kwargs={'__internal_jinja': ParamValue("frozen_rougail.leader.leader"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']), '__internal_attribute': ParamValue("frozen"), '__internal_variable': ParamValue("rougail.leader.leader"), 'when': ParamValue(True), 'inverse': ParamValue(False), '__.condition': ParamOption(option_2, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml'], 'type': 'string'})
|
||||||
option_5 = StrOption(name="follower", doc="a follower", multi=True, properties=frozenset({"basic", "force_default_on_freeze", "mandatory", Calculation(func['jinja_to_property'], Params((ParamValue("frozen"), ParamValue("if condition is no")), kwargs={'__internal_jinja': ParamValue("frozen_rougail.leader.follower"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']), '__internal_attribute': ParamValue("frozen"), '__internal_variable': ParamValue("rougail.leader.follower"), 'when': ParamValue(True), 'inverse': ParamValue(False), '__.condition': ParamOption(option_2, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml'], 'type': 'string'})
|
option_5 = StrOption(name="follower", doc="a follower", multi=True, properties=frozenset({"basic", "force_default_on_freeze", "mandatory", Calculation(func['jinja_to_property'], Params((ParamValue("frozen"), ParamValue("if condition is no")), kwargs={'__internal_jinja': ParamValue("frozen_rougail.leader.follower"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']), '__internal_attribute': ParamValue("frozen"), '__internal_variable': ParamValue("rougail.leader.follower"), 'when': ParamValue(True), 'inverse': ParamValue(False), '__.condition': ParamOption(option_2, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml'], 'type': 'string'})
|
||||||
optiondescription_3 = Leadership(name="leader", doc="a leadership", children=[option_4, option_5], properties=frozenset({"basic", Calculation(func['jinja_to_property'], Params((ParamValue("hidden"), ParamValue("if condition is no")), kwargs={'__internal_jinja': ParamValue("hidden_rougail.leader.leader"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']), '__internal_attribute': ParamValue("hidden"), '__internal_variable': ParamValue("rougail.leader.leader"), 'when': ParamValue(True), 'inverse': ParamValue(False), '__.condition': ParamOption(option_2, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']})
|
optiondescription_3 = Leadership(name="leader", doc="a leadership", children=[option_4, option_5], properties=frozenset({"basic", Calculation(func['jinja_to_property'], Params((ParamValue("hidden"), ParamValue("if condition is no")), kwargs={'__internal_jinja': ParamValue("hidden_rougail.leader"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']), '__internal_attribute': ParamValue("hidden"), '__internal_variable': ParamValue("rougail.leader"), 'when': ParamValue(True), 'inverse': ParamValue(False), '__.condition': ParamOption(option_2, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']})
|
||||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, optiondescription_3], properties=frozenset({"basic"}))
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, optiondescription_3], properties=frozenset({"basic"}))
|
||||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@ ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
dict_env['frozen_leader.leader'] = "{% if __.condition == \"no\" %}\ncondition is no\n{% endif %}\n"
|
dict_env['frozen_leader.leader'] = "{% if __.condition == \"no\" %}\ncondition is no\n{% endif %}\n"
|
||||||
dict_env['frozen_leader.follower'] = "{% if __.condition == \"no\" %}\ncondition is no\n{% endif %}\n"
|
dict_env['frozen_leader.follower'] = "{% if __.condition == \"no\" %}\ncondition is no\n{% endif %}\n"
|
||||||
dict_env['hidden_leader.leader'] = "{% if __.condition == \"no\" %}\ncondition is no\n{% endif %}\n"
|
dict_env['hidden_leader'] = "{% if __.condition == \"no\" %}\ncondition is no\n{% endif %}\n"
|
||||||
option_1 = StrOption(name="condition", doc="a condition", default="no", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml'], 'type': 'string'})
|
option_1 = StrOption(name="condition", doc="a condition", default="no", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml'], 'type': 'string'})
|
||||||
option_3 = StrOption(name="leader", doc="a leader", multi=True, properties=frozenset({"force_default_on_freeze", "standard", Calculation(func['jinja_to_property'], Params((ParamValue("frozen"), ParamValue("if condition is no")), kwargs={'__internal_jinja': ParamValue("frozen_leader.leader"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']), '__internal_attribute': ParamValue("frozen"), '__internal_variable': ParamValue("leader.leader"), 'when': ParamValue(True), 'inverse': ParamValue(False), '__.condition': ParamOption(option_1, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml'], 'type': 'string'})
|
option_3 = StrOption(name="leader", doc="a leader", multi=True, properties=frozenset({"force_default_on_freeze", "standard", Calculation(func['jinja_to_property'], Params((ParamValue("frozen"), ParamValue("if condition is no")), kwargs={'__internal_jinja': ParamValue("frozen_leader.leader"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']), '__internal_attribute': ParamValue("frozen"), '__internal_variable': ParamValue("leader.leader"), 'when': ParamValue(True), 'inverse': ParamValue(False), '__.condition': ParamOption(option_1, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml'], 'type': 'string'})
|
||||||
option_4 = StrOption(name="follower", doc="a follower", multi=True, properties=frozenset({"basic", "force_default_on_freeze", "mandatory", Calculation(func['jinja_to_property'], Params((ParamValue("frozen"), ParamValue("if condition is no")), kwargs={'__internal_jinja': ParamValue("frozen_leader.follower"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']), '__internal_attribute': ParamValue("frozen"), '__internal_variable': ParamValue("leader.follower"), 'when': ParamValue(True), 'inverse': ParamValue(False), '__.condition': ParamOption(option_1, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml'], 'type': 'string'})
|
option_4 = StrOption(name="follower", doc="a follower", multi=True, properties=frozenset({"basic", "force_default_on_freeze", "mandatory", Calculation(func['jinja_to_property'], Params((ParamValue("frozen"), ParamValue("if condition is no")), kwargs={'__internal_jinja': ParamValue("frozen_leader.follower"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']), '__internal_attribute': ParamValue("frozen"), '__internal_variable': ParamValue("leader.follower"), 'when': ParamValue(True), 'inverse': ParamValue(False), '__.condition': ParamOption(option_1, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml'], 'type': 'string'})
|
||||||
optiondescription_2 = Leadership(name="leader", doc="a leadership", children=[option_3, option_4], properties=frozenset({"basic", Calculation(func['jinja_to_property'], Params((ParamValue("hidden"), ParamValue("if condition is no")), kwargs={'__internal_jinja': ParamValue("hidden_leader.leader"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']), '__internal_attribute': ParamValue("hidden"), '__internal_variable': ParamValue("leader.leader"), 'when': ParamValue(True), 'inverse': ParamValue(False), '__.condition': ParamOption(option_1, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']})
|
optiondescription_2 = Leadership(name="leader", doc="a leadership", children=[option_3, option_4], properties=frozenset({"basic", Calculation(func['jinja_to_property'], Params((ParamValue("hidden"), ParamValue("if condition is no")), kwargs={'__internal_jinja': ParamValue("hidden_leader"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']), '__internal_attribute': ParamValue("hidden"), '__internal_variable': ParamValue("leader"), 'when': ParamValue(True), 'inverse': ParamValue(False), '__.condition': ParamOption(option_1, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'ymlfiles': ['../rougail-tests/structures/44_5leadership_leader_hidden_calculation/rougail/00-base.yml']})
|
||||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, optiondescription_2])
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, optiondescription_2])
|
||||||
|
|
|
||||||
|
|
@ -44,12 +44,7 @@ def type_variable(test_name):
|
||||||
loaded_configuration = load(fh)
|
loaded_configuration = load(fh)
|
||||||
assert loaded_configuration == loads(dumps(configuration)), f"error in file {variables_file}"
|
assert loaded_configuration == loads(dumps(configuration)), f"error in file {variables_file}"
|
||||||
#
|
#
|
||||||
print('--------------')
|
|
||||||
print('--------------')
|
|
||||||
print('--------------')
|
|
||||||
print(config.value.get())
|
|
||||||
config.property.read_write()
|
config.property.read_write()
|
||||||
print(config.value.get())
|
|
||||||
variables_file = result / "variables_rw.json"
|
variables_file = result / "variables_rw.json"
|
||||||
configuration = dict(config_to_dict(config.value.get()))
|
configuration = dict(config_to_dict(config.value.get()))
|
||||||
if not variables_file.is_file():
|
if not variables_file.is_file():
|
||||||
|
|
|
||||||
3
tests/types/result/family/variables_rw.json
Normal file
3
tests/types/result/family/variables_rw.json
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.my_family.my_type": "a value"
|
||||||
|
}
|
||||||
8
tests/types/result/family_redefine/variables_rw.json
Normal file
8
tests/types/result/family_redefine/variables_rw.json
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"rougail.my_family_1.a_first_variable": "a modified value",
|
||||||
|
"rougail.my_family_1.a_second_variable": "a modified value",
|
||||||
|
"rougail.my_family_2.a_first_variable": "a value",
|
||||||
|
"rougail.my_family_2.a_second_variable": null,
|
||||||
|
"rougail.my_family_3.a_first_variable": "a value",
|
||||||
|
"rougail.my_family_3.a_second_variable": "a modified value 2"
|
||||||
|
}
|
||||||
8
tests/types/result/family_subfamily/variables_rw.json
Normal file
8
tests/types/result/family_subfamily/variables_rw.json
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"rougail.my_family_1.a_first_variable": "a modified value",
|
||||||
|
"rougail.my_family_1.a_sub_family.a_second_variable": "a modified value",
|
||||||
|
"rougail.my_family_2.a_first_variable": "a value",
|
||||||
|
"rougail.my_family_2.a_sub_family.a_second_variable": null,
|
||||||
|
"rougail.my_family_3.a_first_variable": "a value",
|
||||||
|
"rougail.my_family_3.a_sub_family.a_second_variable": "a modified value 2"
|
||||||
|
}
|
||||||
3
tests/types/result/variable/variables_rw.json
Normal file
3
tests/types/result/variable/variables_rw.json
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.my_var": "a value"
|
||||||
|
}
|
||||||
22
tests/types/result/variable_hidden/tiramisu.py
Normal file
22
tests/types/result/variable_hidden/tiramisu.py
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from re import compile as re_compile
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
try:
|
||||||
|
groups.namespace
|
||||||
|
except:
|
||||||
|
groups.addgroup('namespace')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_3 = StrOption(name="a_first_variable", doc="a first variable", default="a modified value", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['tests/types/types/variable_hidden/00_structure.yml', 'tests/types/structures/variable_hidden/00_structure.yml'], 'type': 'string'})
|
||||||
|
option_4 = StrOption(name="a_second_variable", doc="a second variable", default="a modified value", properties=frozenset({"force_default_on_freeze", "mandatory", "standard", Calculation(func['variable_to_property'], Params((), kwargs={'value': ParamOption(option_3), 'prop': ParamValue("hidden"), 'when': ParamValue("a value"), 'inverse': ParamValue(True)}), help_function=func['variable_to_property']), Calculation(func['variable_to_property'], Params((), kwargs={'value': ParamOption(option_3), 'prop': ParamValue("frozen"), 'when': ParamValue("a value"), 'inverse': ParamValue(True)}), help_function=func['variable_to_property'])}), informations={'ymlfiles': ['tests/types/types/variable_hidden/00_structure.yml', 'tests/types/structures/variable_hidden/00_structure.yml'], 'type': 'string'})
|
||||||
|
optiondescription_2 = OptionDescription(name="my_family_1", doc="My family type", children=[option_3, option_4], properties=frozenset({"standard"}), informations={'ymlfiles': ['tests/types/types/variable_hidden/00_structure.yml', 'tests/types/structures/variable_hidden/00_structure.yml']})
|
||||||
|
option_6 = StrOption(name="a_first_variable", doc="a first variable", default="a value", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['tests/types/types/variable_hidden/00_structure.yml'], 'type': 'string'})
|
||||||
|
option_7 = StrOption(name="a_second_variable", doc="a second variable", properties=frozenset({"basic", "force_default_on_freeze", "mandatory", Calculation(func['variable_to_property'], Params((), kwargs={'value': ParamOption(option_6), 'prop': ParamValue("hidden"), 'when': ParamValue("a value"), 'inverse': ParamValue(True)}), help_function=func['variable_to_property']), Calculation(func['variable_to_property'], Params((), kwargs={'value': ParamOption(option_6), 'prop': ParamValue("frozen"), 'when': ParamValue("a value"), 'inverse': ParamValue(True)}), help_function=func['variable_to_property'])}), informations={'ymlfiles': ['tests/types/types/variable_hidden/00_structure.yml'], 'type': 'string'})
|
||||||
|
optiondescription_5 = OptionDescription(name="my_family_2", doc="My family type", children=[option_6, option_7], properties=frozenset({"basic"}), informations={'ymlfiles': ['tests/types/types/variable_hidden/00_structure.yml', 'tests/types/structures/variable_hidden/00_structure.yml']})
|
||||||
|
option_9 = StrOption(name="a_first_variable", doc="a first variable", default="a value", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['tests/types/types/variable_hidden/00_structure.yml'], 'type': 'string'})
|
||||||
|
option_10 = StrOption(name="a_second_variable", doc="a second variable", default="a modified value 2", properties=frozenset({"force_default_on_freeze", "mandatory", "standard", Calculation(func['variable_to_property'], Params((), kwargs={'value': ParamOption(option_9), 'prop': ParamValue("hidden"), 'when': ParamValue("a value"), 'inverse': ParamValue(True)}), help_function=func['variable_to_property']), Calculation(func['variable_to_property'], Params((), kwargs={'value': ParamOption(option_9), 'prop': ParamValue("frozen"), 'when': ParamValue("a value"), 'inverse': ParamValue(True)}), help_function=func['variable_to_property'])}), informations={'ymlfiles': ['tests/types/types/variable_hidden/00_structure.yml', 'tests/types/structures/variable_hidden/00_structure.yml'], 'type': 'string'})
|
||||||
|
optiondescription_8 = OptionDescription(name="my_family_3", doc="My family type", children=[option_9, option_10], properties=frozenset({"standard"}), informations={'ymlfiles': ['tests/types/types/variable_hidden/00_structure.yml', 'tests/types/structures/variable_hidden/00_structure.yml']})
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="rougail", group_type=groups.namespace, children=[optiondescription_2, optiondescription_5, optiondescription_8], properties=frozenset({"basic"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||||
7
tests/types/result/variable_hidden/variables.json
Normal file
7
tests/types/result/variable_hidden/variables.json
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"rougail.my_family_1.a_first_variable": "a modified value",
|
||||||
|
"rougail.my_family_2.a_first_variable": "a value",
|
||||||
|
"rougail.my_family_2.a_second_variable": null,
|
||||||
|
"rougail.my_family_3.a_first_variable": "a value",
|
||||||
|
"rougail.my_family_3.a_second_variable": "a modified value 2"
|
||||||
|
}
|
||||||
7
tests/types/result/variable_hidden/variables_rw.json
Normal file
7
tests/types/result/variable_hidden/variables_rw.json
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"rougail.my_family_1.a_first_variable": "a modified value",
|
||||||
|
"rougail.my_family_2.a_first_variable": "a value",
|
||||||
|
"rougail.my_family_2.a_second_variable": null,
|
||||||
|
"rougail.my_family_3.a_first_variable": "a value",
|
||||||
|
"rougail.my_family_3.a_second_variable": "a modified value 2"
|
||||||
|
}
|
||||||
5
tests/types/result/variables/variables_rw.json
Normal file
5
tests/types/result/variables/variables_rw.json
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"rougail.my_var1": "a value",
|
||||||
|
"rougail.my_var2": "a value",
|
||||||
|
"rougail.my_var3": null
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue