feat(#28): default value for a calculated variable with an unknown optional variable
This commit is contained in:
parent
bbcffffb82
commit
5e0af148d5
91 changed files with 927 additions and 27 deletions
|
|
@ -37,7 +37,7 @@ from ..utils import (
|
||||||
)
|
)
|
||||||
from ..i18n import _
|
from ..i18n import _
|
||||||
from ..error import DictConsistencyError, VariableCalculationDependencyError
|
from ..error import DictConsistencyError, VariableCalculationDependencyError
|
||||||
from ..tiramisu import CONVERT_OPTION, RENAME_TYPE, display_xmlfiles
|
from ..tiramisu import CONVERT_OPTION, RENAME_TYPE, display_xmlfiles, convert_boolean
|
||||||
|
|
||||||
BASETYPE = Union[StrictBool, StrictInt, StrictFloat, StrictStr, None]
|
BASETYPE = Union[StrictBool, StrictInt, StrictFloat, StrictStr, None]
|
||||||
|
|
||||||
|
|
@ -425,6 +425,7 @@ class _VariableCalculation(Calculation):
|
||||||
variable: StrictStr
|
variable: StrictStr
|
||||||
propertyerror: bool = True
|
propertyerror: bool = True
|
||||||
allow_none: bool = False
|
allow_none: bool = False
|
||||||
|
optional: bool = False
|
||||||
|
|
||||||
def get_variable(
|
def get_variable(
|
||||||
self,
|
self,
|
||||||
|
|
@ -629,19 +630,41 @@ class _VariableCalculation(Calculation):
|
||||||
)
|
)
|
||||||
raise DictConsistencyError(msg, 18, self.xmlfiles)
|
raise DictConsistencyError(msg, 18, self.xmlfiles)
|
||||||
|
|
||||||
|
def get_default_value_optional(self, objectspace, default):
|
||||||
|
if self.attribute_name == "default":
|
||||||
|
if self.inside_list:
|
||||||
|
expected_multiple_value = False
|
||||||
|
elif self.path in objectspace.followers:
|
||||||
|
expected_multiple_value = objectspace.multis[self.path] == "submulti"
|
||||||
|
else:
|
||||||
|
expected_multiple_value = self.path in objectspace.multis
|
||||||
|
elif self.attribute_name in PROPERTY_ATTRIBUTE:
|
||||||
|
expected_multiple_value = False
|
||||||
|
else:
|
||||||
|
expected_multiple_value = True
|
||||||
|
value_is_multi = isinstance(default, list)
|
||||||
|
if expected_multiple_value != value_is_multi:
|
||||||
|
if self.attribute_name != "default" or expected_multiple_value:
|
||||||
|
msg = _('the variable "{0}" is waiting for a list as "{1}" but the attribute "default" is not a list ("{2}")')
|
||||||
|
else:
|
||||||
|
msg = _('the variable "{0}" is not waiting for a list as "{1}" but the attribute "default" is a list ("{2}")')
|
||||||
|
msg = msg.format(self.path, self.attribute_name, default)
|
||||||
|
raise DictConsistencyError(msg, 77, self.xmlfiles)
|
||||||
|
return default
|
||||||
|
|
||||||
|
|
||||||
class VariableCalculation(_VariableCalculation):
|
class VariableCalculation(_VariableCalculation):
|
||||||
attribute_name: Literal["default", "choices", "dynamic"]
|
attribute_name: Literal["default", "choices", "dynamic"]
|
||||||
optional: bool = False
|
|
||||||
description: Optional[StrictStr] = None
|
description: Optional[StrictStr] = None
|
||||||
|
default: Any = undefined
|
||||||
|
|
||||||
def to_function(
|
def to_function(
|
||||||
self,
|
self,
|
||||||
objectspace,
|
objectspace,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
if self.attribute_name != "default" and self.optional:
|
if self.attribute_name != "default" and self.optional and self.default is undefined:
|
||||||
msg = _(
|
msg = _(
|
||||||
'"{0}" attribut shall not have an "optional" attribute for variable "{1}"'
|
'"{0}" attribut shall not have an "optional" attribute without the "default" attribute for variable "{1}"'
|
||||||
).format(self.attribute_name, self.variable)
|
).format(self.attribute_name, self.variable)
|
||||||
raise DictConsistencyError(msg, 33, self.xmlfiles)
|
raise DictConsistencyError(msg, 33, self.xmlfiles)
|
||||||
(
|
(
|
||||||
|
|
@ -654,6 +677,8 @@ class VariableCalculation(_VariableCalculation):
|
||||||
and self.optional
|
and self.optional
|
||||||
or (objectspace.force_optional and self.attribute_name == "default")
|
or (objectspace.force_optional and self.attribute_name == "default")
|
||||||
):
|
):
|
||||||
|
if self.default is not undefined:
|
||||||
|
return self.get_default_value_optional(objectspace, self.default)
|
||||||
raise VariableCalculationDependencyError()
|
raise VariableCalculationDependencyError()
|
||||||
if variable_in_calculation and self.attribute_name == "default":
|
if variable_in_calculation and self.attribute_name == "default":
|
||||||
local_variable = objectspace.paths[self.path]
|
local_variable = objectspace.paths[self.path]
|
||||||
|
|
@ -677,11 +702,11 @@ class VariableCalculation(_VariableCalculation):
|
||||||
|
|
||||||
|
|
||||||
class VariablePropertyCalculation(_VariableCalculation):
|
class VariablePropertyCalculation(_VariableCalculation):
|
||||||
# For python 3.9 attribute_name: Literal[*PROPERTY_ATTRIBUTE]
|
attribute_name: Literal[*PROPERTY_ATTRIBUTE]
|
||||||
attribute_name: Literal["frozen", "hidden", "disabled", "mandatory"]
|
|
||||||
when: Any = undefined
|
when: Any = undefined
|
||||||
when_not: Any = undefined
|
when_not: Any = undefined
|
||||||
description: Optional[StrictStr] = None
|
description: Optional[StrictStr] = None
|
||||||
|
default: bool = False
|
||||||
|
|
||||||
def to_function(
|
def to_function(
|
||||||
self,
|
self,
|
||||||
|
|
@ -692,6 +717,21 @@ class VariablePropertyCalculation(_VariableCalculation):
|
||||||
variable_in_calculation,
|
variable_in_calculation,
|
||||||
variable_in_calculation_identifier,
|
variable_in_calculation_identifier,
|
||||||
) = self.get_variable(objectspace)
|
) = self.get_variable(objectspace)
|
||||||
|
if (
|
||||||
|
# self.default is not undefined and
|
||||||
|
not variable_in_calculation
|
||||||
|
and self.optional
|
||||||
|
or (objectspace.force_optional)
|
||||||
|
):
|
||||||
|
if self.default is undefined:
|
||||||
|
default = False
|
||||||
|
else:
|
||||||
|
default = self.default
|
||||||
|
if not isinstance(default, bool):
|
||||||
|
msg = _('the variable "{0}" is waiting for a boolean as "{1}" but the attribute "default" is not a boolean ("{2}")')
|
||||||
|
msg = msg.format(self.path, self.attribute_name, default)
|
||||||
|
raise DictConsistencyError(msg, 79, self.xmlfiles)
|
||||||
|
return self.get_default_value_optional(objectspace, default)
|
||||||
params = self.get_params(
|
params = self.get_params(
|
||||||
objectspace,
|
objectspace,
|
||||||
variable_in_calculation_path,
|
variable_in_calculation_path,
|
||||||
|
|
@ -823,8 +863,7 @@ class IdentifierCalculation(_IdentifierCalculation):
|
||||||
|
|
||||||
|
|
||||||
class IdentifierPropertyCalculation(_IdentifierCalculation):
|
class IdentifierPropertyCalculation(_IdentifierCalculation):
|
||||||
# for python 3.9 attribute_name: Literal[*PROPERTY_ATTRIBUTE]
|
attribute_name: Literal[*PROPERTY_ATTRIBUTE]
|
||||||
attribute_name: Literal["frozen", "hidden", "disabled", "mandatory"]
|
|
||||||
when: Any = undefined
|
when: Any = undefined
|
||||||
when_not: Any = undefined
|
when_not: Any = undefined
|
||||||
description: Optional[StrictStr] = None
|
description: Optional[StrictStr] = None
|
||||||
|
|
@ -896,10 +935,7 @@ class NamespaceCalculation(Calculation):
|
||||||
namespace = self.namespace
|
namespace = self.namespace
|
||||||
if namespace:
|
if namespace:
|
||||||
namespace = objectspace.paths[namespace].description
|
namespace = objectspace.paths[namespace].description
|
||||||
return {
|
return namespace
|
||||||
"function": "calc_value",
|
|
||||||
"params": {None: [namespace]},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CALCULATION_TYPES = {
|
CALCULATION_TYPES = {
|
||||||
|
|
|
||||||
|
|
@ -221,14 +221,28 @@ class Common:
|
||||||
properties = []
|
properties = []
|
||||||
calc_properties = []
|
calc_properties = []
|
||||||
for property_, value in values.items():
|
for property_, value in values.items():
|
||||||
if value is True:
|
if not isinstance(value, list):
|
||||||
properties.append(self.convert_str(property_))
|
value = [value]
|
||||||
elif isinstance(value, list):
|
for val in value:
|
||||||
for val in value:
|
ret = self.calculation_property(val)
|
||||||
calc_properties.append(self.calculation_value(val))
|
if isinstance(ret, bool):
|
||||||
else:
|
properties.append(self.convert_str(property_))
|
||||||
calc_properties.append(self.calculation_value(value))
|
elif ret is not None:
|
||||||
return "frozenset({" + ", ".join(sorted(properties) + calc_properties) + "})"
|
calc_properties.append(ret)
|
||||||
|
if properties or calc_properties:
|
||||||
|
return "frozenset({" + ", ".join(sorted(properties) + calc_properties) + "})"
|
||||||
|
raise Exception('ca existe alors ...')
|
||||||
|
|
||||||
|
def calculation_property(
|
||||||
|
self,
|
||||||
|
value: Union[Calculation, bool],
|
||||||
|
) -> Optional[bool]:
|
||||||
|
if isinstance(value, Calculation):
|
||||||
|
try:
|
||||||
|
return self.calculation_value(value)
|
||||||
|
except VariableCalculationDependencyError:
|
||||||
|
return None
|
||||||
|
return value
|
||||||
|
|
||||||
def calc_properties(
|
def calc_properties(
|
||||||
self,
|
self,
|
||||||
|
|
@ -358,6 +372,10 @@ class Common:
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Generate calculated value"""
|
"""Generate calculated value"""
|
||||||
child = function.to_function(self.objectspace)
|
child = function.to_function(self.objectspace)
|
||||||
|
if isinstance(child, str):
|
||||||
|
return self.convert_str(child)
|
||||||
|
elif not isinstance(child, dict):
|
||||||
|
return child
|
||||||
new_args = []
|
new_args = []
|
||||||
kwargs = []
|
kwargs = []
|
||||||
if "params" in child:
|
if "params" in child:
|
||||||
|
|
@ -387,10 +405,10 @@ class Common:
|
||||||
datas: Union[Calculation, str, list],
|
datas: Union[Calculation, str, list],
|
||||||
return_a_tuple: bool = False,
|
return_a_tuple: bool = False,
|
||||||
) -> str:
|
) -> str:
|
||||||
if isinstance(datas, str):
|
|
||||||
return self.convert_str(datas)
|
|
||||||
if isinstance(datas, Calculation):
|
if isinstance(datas, Calculation):
|
||||||
return self.calculation_value(datas)
|
datas = self.calculation_value(datas)
|
||||||
|
elif isinstance(datas, str):
|
||||||
|
datas = self.convert_str(datas)
|
||||||
if not isinstance(datas, list):
|
if not isinstance(datas, list):
|
||||||
return datas
|
return datas
|
||||||
params = []
|
params = []
|
||||||
|
|
@ -399,9 +417,11 @@ class Common:
|
||||||
try:
|
try:
|
||||||
params.append(self.calculation_value(data))
|
params.append(self.calculation_value(data))
|
||||||
except VariableCalculationDependencyError:
|
except VariableCalculationDependencyError:
|
||||||
pass
|
continue
|
||||||
elif isinstance(data, str):
|
elif isinstance(data, str):
|
||||||
params.append(self.convert_str(data))
|
params.append(self.convert_str(data))
|
||||||
|
elif isinstance(data, dict):
|
||||||
|
params.append(data)
|
||||||
else:
|
else:
|
||||||
params.append(str(data))
|
params.append(str(data))
|
||||||
if return_a_tuple:
|
if return_a_tuple:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": []
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": [],
|
||||||
|
"rougail.var2": []
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": []
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
["rougail.var1", "rougail.var2"]
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": [],
|
||||||
|
"rougail.var2": []
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": null,
|
||||||
|
"rougail.var2": null,
|
||||||
|
"rougail.var3": null
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
["rougail.var1", "rougail.var2", "rougail.var3"]
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": null,
|
||||||
|
"rougail.var2": null,
|
||||||
|
"rougail.var3": null
|
||||||
|
}
|
||||||
26
tests/dictionaries/00_6integer/makedict/after.json
Normal file
26
tests/dictionaries/00_6integer/makedict/after.json
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"rougail.var4": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
"rougail.var5": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
"rougail.var6": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
8
tests/dictionaries/00_6integer/makedict/base.json
Normal file
8
tests/dictionaries/00_6integer/makedict/base.json
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": 0,
|
||||||
|
"rougail.var2": 0,
|
||||||
|
"rougail.var3": 0,
|
||||||
|
"rougail.var4": 10,
|
||||||
|
"rougail.var5": 10,
|
||||||
|
"rougail.var6": 10
|
||||||
|
}
|
||||||
26
tests/dictionaries/00_6integer/makedict/before.json
Normal file
26
tests/dictionaries/00_6integer/makedict/before.json
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"rougail.var4": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
"rougail.var5": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
"rougail.var6": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
1
tests/dictionaries/00_6integer/makedict/mandatory.json
Normal file
1
tests/dictionaries/00_6integer/makedict/mandatory.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
8
tests/dictionaries/00_6integer/makedict/read_write.json
Normal file
8
tests/dictionaries/00_6integer/makedict/read_write.json
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": 0,
|
||||||
|
"rougail.var2": 0,
|
||||||
|
"rougail.var3": 0,
|
||||||
|
"rougail.var4": 10,
|
||||||
|
"rougail.var5": 10,
|
||||||
|
"rougail.var6": 10
|
||||||
|
}
|
||||||
14
tests/dictionaries/00_6ip/makedict/after.json
Normal file
14
tests/dictionaries/00_6ip/makedict/after.json
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "1.1.1.1"
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "1.1.1.1/24"
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "1.1.1.1/24"
|
||||||
|
}
|
||||||
|
}
|
||||||
5
tests/dictionaries/00_6ip/makedict/base.json
Normal file
5
tests/dictionaries/00_6ip/makedict/base.json
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": "1.1.1.1",
|
||||||
|
"rougail.var2": "1.1.1.1/24",
|
||||||
|
"rougail.var3": "1.1.1.1/24"
|
||||||
|
}
|
||||||
14
tests/dictionaries/00_6ip/makedict/before.json
Normal file
14
tests/dictionaries/00_6ip/makedict/before.json
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "1.1.1.1"
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "1.1.1.1/24"
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "1.1.1.1/24"
|
||||||
|
}
|
||||||
|
}
|
||||||
1
tests/dictionaries/00_6ip/makedict/mandatory.json
Normal file
1
tests/dictionaries/00_6ip/makedict/mandatory.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
5
tests/dictionaries/00_6ip/makedict/read_write.json
Normal file
5
tests/dictionaries/00_6ip/makedict/read_write.json
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": "1.1.1.1",
|
||||||
|
"rougail.var2": "1.1.1.1/24",
|
||||||
|
"rougail.var3": "1.1.1.1/24"
|
||||||
|
}
|
||||||
14
tests/dictionaries/00_6network/makedict/after.json
Normal file
14
tests/dictionaries/00_6network/makedict/after.json
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "1.1.1.0"
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "1.1.1.0/24"
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "1.1.1.0/24"
|
||||||
|
}
|
||||||
|
}
|
||||||
5
tests/dictionaries/00_6network/makedict/base.json
Normal file
5
tests/dictionaries/00_6network/makedict/base.json
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": "1.1.1.0",
|
||||||
|
"rougail.var2": "1.1.1.0/24",
|
||||||
|
"rougail.var3": "1.1.1.0/24"
|
||||||
|
}
|
||||||
14
tests/dictionaries/00_6network/makedict/before.json
Normal file
14
tests/dictionaries/00_6network/makedict/before.json
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "1.1.1.0"
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "1.1.1.0/24"
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "1.1.1.0/24"
|
||||||
|
}
|
||||||
|
}
|
||||||
1
tests/dictionaries/00_6network/makedict/mandatory.json
Normal file
1
tests/dictionaries/00_6network/makedict/mandatory.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
5
tests/dictionaries/00_6network/makedict/read_write.json
Normal file
5
tests/dictionaries/00_6network/makedict/read_write.json
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": "1.1.1.0",
|
||||||
|
"rougail.var2": "1.1.1.0/24",
|
||||||
|
"rougail.var3": "1.1.1.0/24"
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,6 @@ except:
|
||||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
option_2 = StrOption(name="variable", doc="a variable", default=Calculation(func['calc_value'], Params((ParamValue("Rougail")))), properties=frozenset({"standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_8calculation_namespace/rougail/00-base.yml'], 'type': 'string'})
|
option_2 = StrOption(name="variable", doc="a variable", default="Rougail", properties=frozenset({"standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_8calculation_namespace/rougail/00-base.yml'], 'type': 'string'})
|
||||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2], properties=frozenset({"standard"}), informations={'ymlfiles': ['']})
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2], properties=frozenset({"standard"}), informations={'ymlfiles': ['']})
|
||||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"rougail.my_variable": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "val1"
|
||||||
|
},
|
||||||
|
"rougail.my_calculated_variable": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"val1",
|
||||||
|
"value"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"rougail.my_variable": "val1",
|
||||||
|
"rougail.my_calculated_variable": [
|
||||||
|
"val1",
|
||||||
|
"value"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"rougail.my_variable": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "val1"
|
||||||
|
},
|
||||||
|
"rougail.my_calculated_variable": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"val1",
|
||||||
|
"value"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"rougail.my_variable": "val1",
|
||||||
|
"rougail.my_calculated_variable": [
|
||||||
|
"val1",
|
||||||
|
"value"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -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 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_9default_calculation_multi_optional_default/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
option_3 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_2)))), "value"], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_9default_calculation_multi_optional_default/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"standard"}), informations={'ymlfiles': ['']})
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
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')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_1 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_9default_calculation_multi_optional_default/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
option_2 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_1)))), "value"], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_1)))), properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_9default_calculation_multi_optional_default/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"rougail.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 9
|
||||||
|
}
|
||||||
|
}
|
||||||
3
tests/dictionaries/00_9default_number/makedict/base.json
Normal file
3
tests/dictionaries/00_9default_number/makedict/base.json
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.var": 9
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"rougail.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 9
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.var": 9
|
||||||
|
}
|
||||||
50
tests/dictionaries/01_6integer_multi/makedict/after.json
Normal file
50
tests/dictionaries/01_6integer_multi/makedict/after.json
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var4": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
10
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var5": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
10
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var6": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
10
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var7": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var8": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
26
tests/dictionaries/01_6integer_multi/makedict/base.json
Normal file
26
tests/dictionaries/01_6integer_multi/makedict/base.json
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"rougail.var2": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"rougail.var3": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"rougail.var4": [
|
||||||
|
10
|
||||||
|
],
|
||||||
|
"rougail.var5": [
|
||||||
|
10
|
||||||
|
],
|
||||||
|
"rougail.var6": [
|
||||||
|
10
|
||||||
|
],
|
||||||
|
"rougail.var7": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"rougail.var8": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
||||||
50
tests/dictionaries/01_6integer_multi/makedict/before.json
Normal file
50
tests/dictionaries/01_6integer_multi/makedict/before.json
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var4": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
10
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var5": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
10
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var6": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
10
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var7": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var8": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"rougail.var2": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"rougail.var3": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"rougail.var4": [
|
||||||
|
10
|
||||||
|
],
|
||||||
|
"rougail.var5": [
|
||||||
|
10
|
||||||
|
],
|
||||||
|
"rougail.var6": [
|
||||||
|
10
|
||||||
|
],
|
||||||
|
"rougail.var7": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"rougail.var8": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"rougail.variable": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.variable": "c"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"rougail.variable": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.variable": "c"
|
||||||
|
}
|
||||||
|
|
@ -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_2 = ChoiceOption(name="variable", doc="a variable", values=("a", "b", "c"), default="c", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/01_9choice_variable_optional/rougail/00-base.yml'], 'type': 'choice'})
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2], properties=frozenset({"standard"}), informations={'ymlfiles': ['']})
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
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')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_1 = ChoiceOption(name="variable", doc="a variable", values=("a", "b", "c"), default="c", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/01_9choice_variable_optional/rougail/00-base.yml'], 'type': 'choice'})
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"rougail.int": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.int": 10
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"rougail.int": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.int": 10
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"rougail.condition": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var4": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"rougail.condition": false,
|
||||||
|
"rougail.var1": null,
|
||||||
|
"rougail.var2": null,
|
||||||
|
"rougail.var3": null,
|
||||||
|
"rougail.var4": null
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"rougail.condition": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var4": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"rougail.condition": false,
|
||||||
|
"rougail.var3": null,
|
||||||
|
"rougail.var4": null
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
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=False, properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'boolean'})
|
||||||
|
option_3 = StrOption(name="var1", doc="a first variable", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
option_4 = StrOption(name="var2", doc="a first variable", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
option_5 = StrOption(name="var3", doc="a second variable", properties=frozenset({"force_default_on_freeze", "standard", Calculation(func['variable_to_property'], Params((ParamValue("hidden"), ParamOption(option_2)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property']), Calculation(func['variable_to_property'], Params((ParamValue("frozen"), ParamOption(option_2)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property'])}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
option_6 = StrOption(name="var4", doc="a forth variable", properties=frozenset({"force_default_on_freeze", "standard", Calculation(func['variable_to_property'], Params((ParamValue("hidden"), ParamOption(option_2)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property']), Calculation(func['variable_to_property'], Params((ParamValue("frozen"), ParamOption(option_2)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property'])}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3, option_4, option_5, option_6], properties=frozenset({"standard"}), informations={'ymlfiles': ['']})
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
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')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_1 = BoolOption(name="condition", doc="a condition", default=False, properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'boolean'})
|
||||||
|
option_2 = StrOption(name="var1", doc="a first variable", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
option_3 = StrOption(name="var2", doc="a first variable", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
option_4 = StrOption(name="var3", doc="a second variable", properties=frozenset({"force_default_on_freeze", "standard", Calculation(func['variable_to_property'], Params((ParamValue("hidden"), ParamOption(option_1)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property']), Calculation(func['variable_to_property'], Params((ParamValue("frozen"), ParamOption(option_1)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property'])}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
option_5 = StrOption(name="var4", doc="a forth variable", properties=frozenset({"force_default_on_freeze", "standard", Calculation(func['variable_to_property'], Params((ParamValue("hidden"), ParamOption(option_1)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property']), Calculation(func['variable_to_property'], Params((ParamValue("frozen"), ParamOption(option_1)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property'])}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2, option_3, option_4, option_5])
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"rougail.leader.leader": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"a",
|
||||||
|
"b",
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.leader.follower1": {
|
||||||
|
"owner": [
|
||||||
|
"default",
|
||||||
|
"default",
|
||||||
|
"default"
|
||||||
|
],
|
||||||
|
"value": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"rougail.leader.leader": [
|
||||||
|
{
|
||||||
|
"rougail.leader.leader": "a",
|
||||||
|
"rougail.leader.follower1": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"rougail.leader.leader": "b",
|
||||||
|
"rougail.leader.follower1": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"rougail.leader.leader": "c",
|
||||||
|
"rougail.leader.follower1": 2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"rougail.leader.leader": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"a",
|
||||||
|
"b",
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.leader.follower1": {
|
||||||
|
"owner": [
|
||||||
|
"default",
|
||||||
|
"default",
|
||||||
|
"default"
|
||||||
|
],
|
||||||
|
"value": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"rougail.leader.leader": [
|
||||||
|
{
|
||||||
|
"rougail.leader.leader": "a",
|
||||||
|
"rougail.leader.follower1": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"rougail.leader.leader": "b",
|
||||||
|
"rougail.leader.follower1": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"rougail.leader.leader": "c",
|
||||||
|
"rougail.leader.follower1": 2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"rougail.leadership.leader": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"a",
|
||||||
|
"b"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.leadership.follower": {
|
||||||
|
"owner": [
|
||||||
|
"error",
|
||||||
|
"default"
|
||||||
|
],
|
||||||
|
"value": [
|
||||||
|
"cannot access to option \"a follower\" at index \"0\" because has property \"disabled\" (the first follower)",
|
||||||
|
"value"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"rougail.leadership.leader": [
|
||||||
|
{
|
||||||
|
"rougail.leadership.leader": "a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"rougail.leadership.leader": "b",
|
||||||
|
"rougail.leadership.follower": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"rougail.leadership.leader": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"a",
|
||||||
|
"b"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.leadership.follower": {
|
||||||
|
"owner": [
|
||||||
|
"error",
|
||||||
|
"default"
|
||||||
|
],
|
||||||
|
"value": [
|
||||||
|
"cannot access to option \"a follower\" at index \"0\" because has property \"disabled\" (the first follower)",
|
||||||
|
"value"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"rougail.leadership.leader": [
|
||||||
|
{
|
||||||
|
"rougail.leadership.leader": "a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"rougail.leadership.leader": "b",
|
||||||
|
"rougail.leadership.follower": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"rougail.dyna.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "val"
|
||||||
|
},
|
||||||
|
"rougail.dynb.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "val"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"rougail.dyna.var": "val",
|
||||||
|
"rougail.dynb.var": "val"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"rougail.dyna.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "val"
|
||||||
|
},
|
||||||
|
"rougail.dynb.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "val"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"rougail.dyna.var": "val",
|
||||||
|
"rougail.dynb.var": "val"
|
||||||
|
}
|
||||||
|
|
@ -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_3 = StrOption(name="var", doc="a variable inside dynamic family", default="val", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/60_0family_dynamic_variable_optional/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
optiondescription_2 = ConvertDynOptionDescription(name="dyn{{ identifier }}", doc="a dynamic family", identifiers=["a", "b"], children=[option_3], properties=frozenset({"standard"}), informations={'dynamic_variable': 'rougail.unknown_var', 'ymlfiles': ['../rougail-tests/structures/60_0family_dynamic_variable_optional/rougail/00-base.yml']})
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2], properties=frozenset({"standard"}), informations={'ymlfiles': ['']})
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
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')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_2 = StrOption(name="var", doc="a variable inside dynamic family", default="val", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/60_0family_dynamic_variable_optional/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
optiondescription_1 = ConvertDynOptionDescription(name="dyn{{ identifier }}", doc="a dynamic family", identifiers=["a", "b"], children=[option_2], properties=frozenset({"standard"}), informations={'dynamic_variable': 'unknown_var', 'ymlfiles': ['../rougail-tests/structures/60_0family_dynamic_variable_optional/rougail/00-base.yml']})
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
my_variable:
|
||||||
|
default: val1
|
||||||
|
my_calculated_variable:
|
||||||
|
multi: true
|
||||||
|
default:
|
||||||
|
variable: _.my_variable_unexists
|
||||||
|
optional: true
|
||||||
|
default: value
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
my_variable:
|
||||||
|
default: val1
|
||||||
|
my_calculated_variable:
|
||||||
|
default:
|
||||||
|
variable: _.my_variable_unexists
|
||||||
|
optional: true
|
||||||
|
default:
|
||||||
|
- value
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
variable:
|
||||||
|
description: a variable
|
||||||
|
choices:
|
||||||
|
variable: _.unknown_variable
|
||||||
|
optional: true
|
||||||
|
default: c
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
"dyn{{ identifier }}":
|
||||||
|
description: a dynamic family
|
||||||
|
dynamic:
|
||||||
|
variable: _.unknown_var
|
||||||
|
optional: true
|
||||||
|
default: a
|
||||||
|
|
||||||
|
var: val # a variable inside dynamic family
|
||||||
|
...
|
||||||
|
|
@ -47,7 +47,7 @@ excludes = set([
|
||||||
])
|
])
|
||||||
test_ok -= excludes
|
test_ok -= excludes
|
||||||
test_raise -= excludes
|
test_raise -= excludes
|
||||||
# test_ok = ['04_5validators_multi3']
|
# test_ok = ['01_9choice_variable_optional']
|
||||||
#test_ok = []
|
#test_ok = []
|
||||||
# test_raise = ['80unknown_default_variable_inside_dynamic_family']
|
# test_raise = ['80unknown_default_variable_inside_dynamic_family']
|
||||||
#test_raise = []
|
#test_raise = []
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ excludes = set([])
|
||||||
|
|
||||||
# excludes = set(['60_5family_dynamic_variable_outside_sub_suffix'])
|
# excludes = set(['60_5family_dynamic_variable_outside_sub_suffix'])
|
||||||
test_ok -= excludes
|
test_ok -= excludes
|
||||||
test_ok = ['44_9calculated_default_leadership_leader']
|
# test_ok = ['04_5disabled_calculation_optional_default']
|
||||||
|
|
||||||
|
|
||||||
test_ok = list(test_ok)
|
test_ok = list(test_ok)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue