diff --git a/src/rougail/object_model.py b/src/rougail/object_model.py index bc5ef324b..5c6ab31c1 100644 --- a/src/rougail/object_model.py +++ b/src/rougail/object_model.py @@ -397,11 +397,9 @@ class _VariableCalculation(Calculation): propertyerror: bool = True allow_none: bool = False - def get_params( - self, - objectspace, - needs_multi: Optional[bool] = None, - ): + def get_variable(self, + objectspace, + ) -> "Variable": if self.ori_path is None: path = self.path else: @@ -414,13 +412,22 @@ class _VariableCalculation(Calculation): self.namespace, self.xmlfiles, ) - if not variable: - if self.optional: - msg = f'the dependent variable was not found "{self.optional}" for variable "{self.path}"' - raise VariableCalculationDependencyError(msg, 90, self.xmlfiles) - if not isinstance(variable, objectspace.variable): + if variable and not isinstance(variable, objectspace.variable): # FIXME remove the pfff raise Exception("pfff it's a family") + return variable, suffix + + def get_params( + self, + objectspace, + variable: "Variable", + suffix: Optional[str], + *, + needs_multi: Optional[bool] = None, + ): + if not variable: + msg = f'Variable not found "{self.variable}" for attribut "{self.attribute_name}" for variable "{self.path}"' + raise DictConsistencyError(msg, 88, self.xmlfiles) param = { "type": "variable", "variable": variable, @@ -477,11 +484,17 @@ class VariableCalculation(_VariableCalculation): self, objectspace, ) -> dict: - params = self.get_params(objectspace) - if self.attribute_name == "choices": - if hasattr(self, "optional") and self.optional is True: - msg = "'choices' variable shall not have an 'optional' atttibute" - raise DictConsistencyError(msg, 33, self.xmlfiles) + if self.attribute_name != "default" and self.optional is True: + msg = f'"{self.attribute_name}" variable shall not have an "optional" attribute for variable "{self.variable}"' + raise DictConsistencyError(msg, 33, self.xmlfiles) + variable, suffix = self.get_variable(objectspace) + if not variable and self.optional: + msg = f'the dependent variable was not found "{self.optional}" for attribute "{self.attribute_name}" in variable "{self.path}"' + raise VariableCalculationDependencyError(msg, 90, self.xmlfiles) + params = self.get_params(objectspace, + variable, + suffix, + ) return { "function": "calc_value", "params": params, @@ -497,7 +510,11 @@ class VariablePropertyCalculation(_VariableCalculation): self, objectspace, ) -> dict: - params = self.get_params(objectspace, False) + variable, suffix = self.get_variable(objectspace) + params = self.get_params(objectspace, + variable, + suffix, + needs_multi=False,) variable = params[None][0]["variable"] if self.when is not undefined: if self.version == "1.0": diff --git a/src/rougail/tiramisureflector.py b/src/rougail/tiramisureflector.py index 06352cb50..c2d51bda9 100644 --- a/src/rougail/tiramisureflector.py +++ b/src/rougail/tiramisureflector.py @@ -409,7 +409,10 @@ class Common: params = [] for idx, data in enumerate(datas): if isinstance(data, Calculation): - params.append(self.calculation_value(data)) + try: + params.append(self.calculation_value(data)) + except VariableCalculationDependencyError: + pass elif isinstance(data, str): params.append(self.convert_str(data)) else: @@ -452,12 +455,6 @@ class Variable(Common): ) return if self.elt.type == "choice": - # TODO : 'optional' sub-attriute shall be forbidden - # raise DictConsistencyError( - # "Sub-attributes not allowed in a 'choices' attribute", - # 100, - # self.elt.xmlfiles, - # ) keys["values"] = self.populate_calculation( self.elt.choices, return_a_tuple=True ) @@ -468,17 +465,13 @@ class Variable(Common): keys["default"] = self.populate_calculation(self.elt.default) except VariableCalculationDependencyError: pass - # for attribute in ["frozen", "hidden", "mandatory", "disabled"]: - # if hasattr(self.elt, attribute): # FIXME FIXME and attribute == "optional": - # raise DictConsistencyError( - # f"Sub-attributes not allowed in a '{attribute}' attribute", - # 100, - # self.elt.xmlfiles, - # ) if self.elt.path in self.objectspace.default_multi: - keys["default_multi"] = self.populate_calculation( - self.objectspace.default_multi[self.elt.path] - ) + try: + keys["default_multi"] = self.populate_calculation( + self.objectspace.default_multi[self.elt.path] + ) + except VariableCalculationDependencyError: + pass if self.elt.validators: keys["validators"] = self.populate_calculation(self.elt.validators) for key, value in ( diff --git a/tests/dictionaries/00_9choice_variables/dictionaries/rougail/00-base.yml b/tests/dictionaries/00_9choice_variables/dictionaries/rougail/00-base.yml index fee7f45f7..d72d8250a 100644 --- a/tests/dictionaries/00_9choice_variables/dictionaries/rougail/00-base.yml +++ b/tests/dictionaries/00_9choice_variables/dictionaries/rougail/00-base.yml @@ -7,7 +7,7 @@ my_variable: type: choice choices: - type: variable - variable: rougail.source_variable_1 + variable: _.source_variable_1 - type: variable - variable: rougail.source_variable_2 + variable: _.source_variable_2 default: val1 diff --git a/tests/dictionaries/00_9choice_variables/tiramisu/no_namespace.py b/tests/dictionaries/00_9choice_variables/tiramisu/no_namespace.py new file mode 100644 index 000000000..94943c699 --- /dev/null +++ b/tests/dictionaries/00_9choice_variables/tiramisu/no_namespace.py @@ -0,0 +1,11 @@ +from tiramisu import * +from tiramisu.setting import ALLOWED_LEADER_PROPERTIES +from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription +load_functions('tests/dictionaries/../eosfunc/test.py') +ALLOWED_LEADER_PROPERTIES.add("basic") +ALLOWED_LEADER_PROPERTIES.add("standard") +ALLOWED_LEADER_PROPERTIES.add("advanced") +option_1 = StrOption(name="source_variable_1", doc="the first source variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_2 = StrOption(name="source_variable_2", doc="the second source variable", default="val2", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_3 = ChoiceOption(name="my_variable", doc="a variable", values=(Calculation(func['calc_value'], Params((ParamOption(option_1)))), Calculation(func['calc_value'], Params((ParamOption(option_2))))), default="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2, option_3]) diff --git a/tests/dictionaries/90_optional_parameter_in_variable_default/__init__.py b/tests/dictionaries/00_9default_calculation_multi_optional/__init__.py similarity index 100% rename from tests/dictionaries/90_optional_parameter_in_variable_default/__init__.py rename to tests/dictionaries/00_9default_calculation_multi_optional/__init__.py diff --git a/tests/dictionaries/00_9default_calculation_multi_optional/dictionaries/rougail/00-base.yml b/tests/dictionaries/00_9default_calculation_multi_optional/dictionaries/rougail/00-base.yml new file mode 100644 index 000000000..b7f77ba8c --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional/dictionaries/rougail/00-base.yml @@ -0,0 +1,13 @@ +--- +version: 1.1 +my_variable: + default: val1 +my_calculated_variable: + multi: true + default: + - type: variable + variable: _.my_variable + optional: true + - type: variable + variable: _.my_variable_unexists + optional: true diff --git a/tests/dictionaries/00_9default_calculation_multi_optional/tiramisu/base.py b/tests/dictionaries/00_9default_calculation_multi_optional/tiramisu/base.py new file mode 100644 index 000000000..04caf8637 --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional/tiramisu/base.py @@ -0,0 +1,11 @@ +from tiramisu import * +from tiramisu.setting import ALLOWED_LEADER_PROPERTIES +from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription +load_functions('tests/dictionaries/../eosfunc/test.py') +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={'type': 'string'}) +option_3 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_2))))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2, option_3], properties=frozenset({"standard"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/00_9default_calculation_multi_optional/tiramisu/multi.py b/tests/dictionaries/00_9default_calculation_multi_optional/tiramisu/multi.py new file mode 100644 index 000000000..646fdd657 --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional/tiramisu/multi.py @@ -0,0 +1,16 @@ +from tiramisu import * +from tiramisu.setting import ALLOWED_LEADER_PROPERTIES +from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription +load_functions('tests/dictionaries/../eosfunc/test.py') +ALLOWED_LEADER_PROPERTIES.add("basic") +ALLOWED_LEADER_PROPERTIES.add("standard") +ALLOWED_LEADER_PROPERTIES.add("advanced") +option_3 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_3))))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_3)))), properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3, option_4], properties=frozenset({"standard"})) +optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"})) +option_7 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_8 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_7))))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_7)))), properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +optiondescription_6 = OptionDescription(name="rougail", doc="Rougail", children=[option_7, option_8], properties=frozenset({"standard"})) +optiondescription_5 = OptionDescription(name="2", doc="2", children=[optiondescription_6], properties=frozenset({"standard"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_5]) diff --git a/tests/dictionaries/00_9default_calculation_multi_optional/tiramisu/no_namespace.py b/tests/dictionaries/00_9default_calculation_multi_optional/tiramisu/no_namespace.py new file mode 100644 index 000000000..2796d5e6a --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional/tiramisu/no_namespace.py @@ -0,0 +1,10 @@ +from tiramisu import * +from tiramisu.setting import ALLOWED_LEADER_PROPERTIES +from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription +load_functions('tests/dictionaries/../eosfunc/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={'type': 'string'}) +option_2 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_1))))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_1)))), properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2]) diff --git a/tests/dictionaries/90_optional_parameter_in_variable_exists/__init__.py b/tests/dictionaries/00_9default_calculation_multi_optional2/__init__.py similarity index 100% rename from tests/dictionaries/90_optional_parameter_in_variable_exists/__init__.py rename to tests/dictionaries/00_9default_calculation_multi_optional2/__init__.py diff --git a/tests/dictionaries/00_9default_calculation_multi_optional2/dictionaries/rougail/00-base.yml b/tests/dictionaries/00_9default_calculation_multi_optional2/dictionaries/rougail/00-base.yml new file mode 100644 index 000000000..57a5ac530 --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional2/dictionaries/rougail/00-base.yml @@ -0,0 +1,13 @@ +--- +version: 1.1 +my_variable: + default: val1 +my_calculated_variable: + multi: true + default: + - type: variable + variable: _.my_variable_unexists + optional: true + - type: variable + variable: _.my_variable + optional: true diff --git a/tests/dictionaries/00_9default_calculation_multi_optional2/tiramisu/base.py b/tests/dictionaries/00_9default_calculation_multi_optional2/tiramisu/base.py new file mode 100644 index 000000000..cbe718bd1 --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional2/tiramisu/base.py @@ -0,0 +1,11 @@ +from tiramisu import * +from tiramisu.setting import ALLOWED_LEADER_PROPERTIES +from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription +load_functions('tests/dictionaries/../eosfunc/test.py') +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={'type': 'string'}) +option_3 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_2))))], properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2, option_3], properties=frozenset({"standard"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/00_9default_calculation_multi_optional2/tiramisu/multi.py b/tests/dictionaries/00_9default_calculation_multi_optional2/tiramisu/multi.py new file mode 100644 index 000000000..085901031 --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional2/tiramisu/multi.py @@ -0,0 +1,16 @@ +from tiramisu import * +from tiramisu.setting import ALLOWED_LEADER_PROPERTIES +from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription +load_functions('tests/dictionaries/../eosfunc/test.py') +ALLOWED_LEADER_PROPERTIES.add("basic") +ALLOWED_LEADER_PROPERTIES.add("standard") +ALLOWED_LEADER_PROPERTIES.add("advanced") +option_3 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_3))))], properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3, option_4], properties=frozenset({"standard"})) +optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"})) +option_7 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_8 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_7))))], properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +optiondescription_6 = OptionDescription(name="rougail", doc="Rougail", children=[option_7, option_8], properties=frozenset({"standard"})) +optiondescription_5 = OptionDescription(name="2", doc="2", children=[optiondescription_6], properties=frozenset({"standard"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_5]) diff --git a/tests/dictionaries/00_9default_calculation_multi_optional2/tiramisu/no_namespace.py b/tests/dictionaries/00_9default_calculation_multi_optional2/tiramisu/no_namespace.py new file mode 100644 index 000000000..2b6888d61 --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional2/tiramisu/no_namespace.py @@ -0,0 +1,10 @@ +from tiramisu import * +from tiramisu.setting import ALLOWED_LEADER_PROPERTIES +from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription +load_functions('tests/dictionaries/../eosfunc/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={'type': 'string'}) +option_2 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_1))))], properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2]) diff --git a/tests/dictionaries/00_9choice_variables/force_namespace b/tests/dictionaries/00_9default_calculation_optional/__init__.py similarity index 100% rename from tests/dictionaries/00_9choice_variables/force_namespace rename to tests/dictionaries/00_9default_calculation_optional/__init__.py diff --git a/tests/dictionaries/90_optional_parameter_in_variable_default/dictionaries/rougail/00-base.yml b/tests/dictionaries/00_9default_calculation_optional/dictionaries/rougail/00-base.yml similarity index 50% rename from tests/dictionaries/90_optional_parameter_in_variable_default/dictionaries/rougail/00-base.yml rename to tests/dictionaries/00_9default_calculation_optional/dictionaries/rougail/00-base.yml index 4a017adc3..7e8c316dc 100644 --- a/tests/dictionaries/90_optional_parameter_in_variable_default/dictionaries/rougail/00-base.yml +++ b/tests/dictionaries/00_9default_calculation_optional/dictionaries/rougail/00-base.yml @@ -1,14 +1,8 @@ --- version: 1.1 -#my_variable: -# multi: true -# default: -# - val1 -# - val2 my_calculated_variable: multi: true default: type: variable - variable: rougail.my_variable + variable: _.my_variable optional: true - diff --git a/tests/dictionaries/00_9default_calculation_optional/tiramisu/base.py b/tests/dictionaries/00_9default_calculation_optional/tiramisu/base.py new file mode 100644 index 000000000..0d5bcd8b0 --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_optional/tiramisu/base.py @@ -0,0 +1,10 @@ +from tiramisu import * +from tiramisu.setting import ALLOWED_LEADER_PROPERTIES +from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription +load_functions('tests/dictionaries/../eosfunc/test.py') +ALLOWED_LEADER_PROPERTIES.add("basic") +ALLOWED_LEADER_PROPERTIES.add("standard") +ALLOWED_LEADER_PROPERTIES.add("advanced") +option_2 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2], properties=frozenset({"standard"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/00_9default_calculation_optional/tiramisu/multi.py b/tests/dictionaries/00_9default_calculation_optional/tiramisu/multi.py new file mode 100644 index 000000000..79139942d --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_optional/tiramisu/multi.py @@ -0,0 +1,14 @@ +from tiramisu import * +from tiramisu.setting import ALLOWED_LEADER_PROPERTIES +from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription +load_functions('tests/dictionaries/../eosfunc/test.py') +ALLOWED_LEADER_PROPERTIES.add("basic") +ALLOWED_LEADER_PROPERTIES.add("standard") +ALLOWED_LEADER_PROPERTIES.add("advanced") +option_3 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3], properties=frozenset({"standard"})) +optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"})) +option_6 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +optiondescription_5 = OptionDescription(name="rougail", doc="Rougail", children=[option_6], properties=frozenset({"standard"})) +optiondescription_4 = OptionDescription(name="2", doc="2", children=[optiondescription_5], properties=frozenset({"standard"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_4]) diff --git a/tests/dictionaries/90_optional_parameter_in_variable_default/tiramisu/no_namespace.py b/tests/dictionaries/00_9default_calculation_optional/tiramisu/no_namespace.py similarity index 58% rename from tests/dictionaries/90_optional_parameter_in_variable_default/tiramisu/no_namespace.py rename to tests/dictionaries/00_9default_calculation_optional/tiramisu/no_namespace.py index 900cb0f70..b89359806 100644 --- a/tests/dictionaries/90_optional_parameter_in_variable_default/tiramisu/no_namespace.py +++ b/tests/dictionaries/00_9default_calculation_optional/tiramisu/no_namespace.py @@ -1,16 +1,9 @@ from tiramisu import * from tiramisu.setting import ALLOWED_LEADER_PROPERTIES from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription - -load_functions("tests/dictionaries/../eosfunc/test.py") +load_functions('tests/dictionaries/../eosfunc/test.py') ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("advanced") -option_1 = StrOption( - name="my_calculated_variable", - doc="my_calculated_variable", - multi=True, - properties=frozenset({"mandatory", "notempty", "standard"}), - informations={"type": "string"}, -) +option_1 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) diff --git a/tests/dictionaries/00_9default_calculation_optional_exists/__init__.py b/tests/dictionaries/00_9default_calculation_optional_exists/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/90_optional_parameter_in_variable_exists/dictionaries/rougail/00-base.yml b/tests/dictionaries/00_9default_calculation_optional_exists/dictionaries/rougail/00-base.yml similarity index 82% rename from tests/dictionaries/90_optional_parameter_in_variable_exists/dictionaries/rougail/00-base.yml rename to tests/dictionaries/00_9default_calculation_optional_exists/dictionaries/rougail/00-base.yml index 61cf089c9..b002d90ce 100644 --- a/tests/dictionaries/90_optional_parameter_in_variable_exists/dictionaries/rougail/00-base.yml +++ b/tests/dictionaries/00_9default_calculation_optional_exists/dictionaries/rougail/00-base.yml @@ -9,6 +9,5 @@ my_calculated_variable: multi: true default: type: variable - variable: rougail.my_variable + variable: _.my_variable optional: true - diff --git a/tests/dictionaries/00_9default_calculation_optional_exists/tiramisu/base.py b/tests/dictionaries/00_9default_calculation_optional_exists/tiramisu/base.py new file mode 100644 index 000000000..07274410f --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_optional_exists/tiramisu/base.py @@ -0,0 +1,11 @@ +from tiramisu import * +from tiramisu.setting import ALLOWED_LEADER_PROPERTIES +from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription +load_functions('tests/dictionaries/../eosfunc/test.py') +ALLOWED_LEADER_PROPERTIES.add("basic") +ALLOWED_LEADER_PROPERTIES.add("standard") +ALLOWED_LEADER_PROPERTIES.add("advanced") +option_2 = StrOption(name="my_variable", doc="my_variable", multi=True, default=["val1", "val2"], default_multi="val1", properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +option_3 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2, option_3], properties=frozenset({"standard"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/00_9default_calculation_optional_exists/tiramisu/multi.py b/tests/dictionaries/00_9default_calculation_optional_exists/tiramisu/multi.py new file mode 100644 index 000000000..70d8f0a7e --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_optional_exists/tiramisu/multi.py @@ -0,0 +1,16 @@ +from tiramisu import * +from tiramisu.setting import ALLOWED_LEADER_PROPERTIES +from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription +load_functions('tests/dictionaries/../eosfunc/test.py') +ALLOWED_LEADER_PROPERTIES.add("basic") +ALLOWED_LEADER_PROPERTIES.add("standard") +ALLOWED_LEADER_PROPERTIES.add("advanced") +option_3 = StrOption(name="my_variable", doc="my_variable", multi=True, default=["val1", "val2"], default_multi="val1", properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_3)))), properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3, option_4], properties=frozenset({"standard"})) +optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"})) +option_7 = StrOption(name="my_variable", doc="my_variable", multi=True, default=["val1", "val2"], default_multi="val1", properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +option_8 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_7)))), properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +optiondescription_6 = OptionDescription(name="rougail", doc="Rougail", children=[option_7, option_8], properties=frozenset({"standard"})) +optiondescription_5 = OptionDescription(name="2", doc="2", children=[optiondescription_6], properties=frozenset({"standard"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_5]) diff --git a/tests/dictionaries/00_9default_calculation_optional_exists/tiramisu/no_namespace.py b/tests/dictionaries/00_9default_calculation_optional_exists/tiramisu/no_namespace.py new file mode 100644 index 000000000..6492b865b --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_optional_exists/tiramisu/no_namespace.py @@ -0,0 +1,10 @@ +from tiramisu import * +from tiramisu.setting import ALLOWED_LEADER_PROPERTIES +from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription +load_functions('tests/dictionaries/../eosfunc/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", multi=True, default=["val1", "val2"], default_multi="val1", properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +option_2 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_1)))), properties=frozenset({"mandatory", "notempty", "standard"}), informations={'type': 'string'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2]) diff --git a/tests/dictionaries/80choice_variable_optional/__init__.py b/tests/dictionaries/80choice_variable_optional/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/80choice_variable_optional/dictionaries/rougail/00-base.yml b/tests/dictionaries/80choice_variable_optional/dictionaries/rougail/00-base.yml new file mode 100644 index 000000000..b2cd51fa0 --- /dev/null +++ b/tests/dictionaries/80choice_variable_optional/dictionaries/rougail/00-base.yml @@ -0,0 +1,11 @@ +--- +version: '1.1' +var1: + - a + - b + - c +var2: + choices: + type: variable + variable: _.var1 + optional: true diff --git a/tests/dictionaries/80choice_variable_optional/errno_33 b/tests/dictionaries/80choice_variable_optional/errno_33 new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/80family_dynamic_optional/__init__.py b/tests/dictionaries/80family_dynamic_optional/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/80family_dynamic_optional/dictionaries/rougail/00-base.yml b/tests/dictionaries/80family_dynamic_optional/dictionaries/rougail/00-base.yml new file mode 100644 index 000000000..3b03d76da --- /dev/null +++ b/tests/dictionaries/80family_dynamic_optional/dictionaries/rougail/00-base.yml @@ -0,0 +1,13 @@ +--- +version: '1.1' +varname: + default: + - val1 +dyn{{ suffix }}: + type: dynamic + dynamic: + type: variable + variable: _.varname + optional: true + vardyn: + type: string diff --git a/tests/dictionaries/80family_dynamic_optional/errno_33 b/tests/dictionaries/80family_dynamic_optional/errno_33 new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/80valid_enum_multi_variable/dictionaries/rougail/00-base.yml b/tests/dictionaries/80valid_enum_multi_variable/dictionaries/rougail/00-base.yml index 47544b8a5..ab8fcfb83 100644 --- a/tests/dictionaries/80valid_enum_multi_variable/dictionaries/rougail/00-base.yml +++ b/tests/dictionaries/80valid_enum_multi_variable/dictionaries/rougail/00-base.yml @@ -1,27 +1,16 @@ -general: - mode_conteneur_actif: - type: choice - description: No change - default: a - choices: +--- +version: '1.1' +var: + - a + - b + - c +var2: + - a + - b + - c +var3: + choices: - type: variable - variable: rougail.general.var + variable: _.var - type: variable - variable: rougail.general.var2 - var: - type: string - description: New variable - multi: true - default: - - a - - b - - c - var2: - type: string - description: New variable - multi: true - default: - - a - - b - - c -version: '1.0' + variable: _.var2 diff --git a/tests/dictionaries/90_optional_parameter_in_variable_default/tiramisu/base.py b/tests/dictionaries/90_optional_parameter_in_variable_default/tiramisu/base.py deleted file mode 100644 index 704faff60..000000000 --- a/tests/dictionaries/90_optional_parameter_in_variable_default/tiramisu/base.py +++ /dev/null @@ -1,24 +0,0 @@ -from tiramisu import * -from tiramisu.setting import ALLOWED_LEADER_PROPERTIES -from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription - -load_functions("tests/dictionaries/../eosfunc/test.py") -ALLOWED_LEADER_PROPERTIES.add("basic") -ALLOWED_LEADER_PROPERTIES.add("standard") -ALLOWED_LEADER_PROPERTIES.add("advanced") -option_2 = StrOption( - name="my_calculated_variable", - doc="my_calculated_variable", - multi=True, - properties=frozenset({"mandatory", "notempty", "standard"}), - informations={"type": "string"}, -) -optiondescription_1 = OptionDescription( - name="rougail", - doc="Rougail", - children=[option_2], - properties=frozenset({"standard"}), -) -option_0 = OptionDescription( - name="baseoption", doc="baseoption", children=[optiondescription_1] -) diff --git a/tests/dictionaries/90_optional_parameter_in_variable_default/tiramisu/multi.py b/tests/dictionaries/90_optional_parameter_in_variable_default/tiramisu/multi.py deleted file mode 100644 index 6bee1bb59..000000000 --- a/tests/dictionaries/90_optional_parameter_in_variable_default/tiramisu/multi.py +++ /dev/null @@ -1,51 +0,0 @@ -from tiramisu import * -from tiramisu.setting import ALLOWED_LEADER_PROPERTIES -from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription - -load_functions("tests/dictionaries/../eosfunc/test.py") -ALLOWED_LEADER_PROPERTIES.add("basic") -ALLOWED_LEADER_PROPERTIES.add("standard") -ALLOWED_LEADER_PROPERTIES.add("advanced") -option_3 = StrOption( - name="my_calculated_variable", - doc="my_calculated_variable", - multi=True, - properties=frozenset({"mandatory", "notempty", "standard"}), - informations={"type": "string"}, -) -optiondescription_2 = OptionDescription( - name="rougail", - doc="Rougail", - children=[option_3], - properties=frozenset({"standard"}), -) -optiondescription_1 = OptionDescription( - name="1", - doc="1", - children=[optiondescription_2], - properties=frozenset({"standard"}), -) -option_6 = StrOption( - name="my_calculated_variable", - doc="my_calculated_variable", - multi=True, - properties=frozenset({"mandatory", "notempty", "standard"}), - informations={"type": "string"}, -) -optiondescription_5 = OptionDescription( - name="rougail", - doc="Rougail", - children=[option_6], - properties=frozenset({"standard"}), -) -optiondescription_4 = OptionDescription( - name="2", - doc="2", - children=[optiondescription_5], - properties=frozenset({"standard"}), -) -option_0 = OptionDescription( - name="baseoption", - doc="baseoption", - children=[optiondescription_1, optiondescription_4], -) diff --git a/tests/dictionaries/90_optional_parameter_in_variable_exists/tiramisu/base.py b/tests/dictionaries/90_optional_parameter_in_variable_exists/tiramisu/base.py deleted file mode 100644 index 324e229ad..000000000 --- a/tests/dictionaries/90_optional_parameter_in_variable_exists/tiramisu/base.py +++ /dev/null @@ -1,34 +0,0 @@ -from tiramisu import * -from tiramisu.setting import ALLOWED_LEADER_PROPERTIES -from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription - -load_functions("tests/dictionaries/../eosfunc/test.py") -ALLOWED_LEADER_PROPERTIES.add("basic") -ALLOWED_LEADER_PROPERTIES.add("standard") -ALLOWED_LEADER_PROPERTIES.add("advanced") -option_2 = StrOption( - name="my_variable", - doc="my_variable", - multi=True, - default=["val1", "val2"], - default_multi="val1", - properties=frozenset({"mandatory", "notempty", "standard"}), - informations={"type": "string"}, -) -option_3 = StrOption( - name="my_calculated_variable", - doc="my_calculated_variable", - multi=True, - default=Calculation(func["calc_value"], Params((ParamOption(option_2)))), - properties=frozenset({"mandatory", "notempty", "standard"}), - informations={"type": "string"}, -) -optiondescription_1 = OptionDescription( - name="rougail", - doc="Rougail", - children=[option_2, option_3], - properties=frozenset({"standard"}), -) -option_0 = OptionDescription( - name="baseoption", doc="baseoption", children=[optiondescription_1] -) diff --git a/tests/dictionaries/90_optional_parameter_in_variable_exists/tiramisu/multi.py b/tests/dictionaries/90_optional_parameter_in_variable_exists/tiramisu/multi.py deleted file mode 100644 index 5eb82f46e..000000000 --- a/tests/dictionaries/90_optional_parameter_in_variable_exists/tiramisu/multi.py +++ /dev/null @@ -1,71 +0,0 @@ -from tiramisu import * -from tiramisu.setting import ALLOWED_LEADER_PROPERTIES -from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription - -load_functions("tests/dictionaries/../eosfunc/test.py") -ALLOWED_LEADER_PROPERTIES.add("basic") -ALLOWED_LEADER_PROPERTIES.add("standard") -ALLOWED_LEADER_PROPERTIES.add("advanced") -option_3 = StrOption( - name="my_variable", - doc="my_variable", - multi=True, - default=["val1", "val2"], - default_multi="val1", - properties=frozenset({"mandatory", "notempty", "standard"}), - informations={"type": "string"}, -) -option_4 = StrOption( - name="my_calculated_variable", - doc="my_calculated_variable", - multi=True, - default=Calculation(func["calc_value"], Params((ParamOption(option_3)))), - properties=frozenset({"mandatory", "notempty", "standard"}), - informations={"type": "string"}, -) -optiondescription_2 = OptionDescription( - name="rougail", - doc="Rougail", - children=[option_3, option_4], - properties=frozenset({"standard"}), -) -optiondescription_1 = OptionDescription( - name="1", - doc="1", - children=[optiondescription_2], - properties=frozenset({"standard"}), -) -option_7 = StrOption( - name="my_variable", - doc="my_variable", - multi=True, - default=["val1", "val2"], - default_multi="val1", - properties=frozenset({"mandatory", "notempty", "standard"}), - informations={"type": "string"}, -) -option_8 = StrOption( - name="my_calculated_variable", - doc="my_calculated_variable", - multi=True, - default=Calculation(func["calc_value"], Params((ParamOption(option_7)))), - properties=frozenset({"mandatory", "notempty", "standard"}), - informations={"type": "string"}, -) -optiondescription_6 = OptionDescription( - name="rougail", - doc="Rougail", - children=[option_7, option_8], - properties=frozenset({"standard"}), -) -optiondescription_5 = OptionDescription( - name="2", - doc="2", - children=[optiondescription_6], - properties=frozenset({"standard"}), -) -option_0 = OptionDescription( - name="baseoption", - doc="baseoption", - children=[optiondescription_1, optiondescription_5], -) diff --git a/tests/dictionaries/90_optional_parameter_in_variable_exists/tiramisu/no_namespace.py b/tests/dictionaries/90_optional_parameter_in_variable_exists/tiramisu/no_namespace.py deleted file mode 100644 index 37ec3f4fc..000000000 --- a/tests/dictionaries/90_optional_parameter_in_variable_exists/tiramisu/no_namespace.py +++ /dev/null @@ -1,27 +0,0 @@ -from tiramisu import * -from tiramisu.setting import ALLOWED_LEADER_PROPERTIES -from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription - -load_functions("tests/dictionaries/../eosfunc/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", - multi=True, - default=["val1", "val2"], - default_multi="val1", - properties=frozenset({"mandatory", "notempty", "standard"}), - informations={"type": "string"}, -) -option_2 = StrOption( - name="my_calculated_variable", - doc="my_calculated_variable", - multi=True, - properties=frozenset({"mandatory", "notempty", "standard"}), - informations={"type": "string"}, -) -option_0 = OptionDescription( - name="baseoption", doc="baseoption", children=[option_1, option_2] -)