From 4c8a3c813a8d711e52ec10b13b0d072e11176219 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 15 Jan 2026 08:33:14 +0100 Subject: [PATCH] fix: types with subfamily --- src/rougail/types.py | 2 +- .../types/result/family_subfamily/tiramisu.py | 25 +++++++++++++++++++ .../result/family_subfamily/variables.json | 8 ++++++ .../family_subfamily/00_structure.yml | 23 +++++++++++++++++ .../variable_hidden/00_structure.yml | 19 ++++++++++++++ .../types/family_redefine/00_structure.yml | 10 ++++++++ .../types/family_subfamily/00_structure.yml | 12 +++++++++ .../types/variable_hidden/00_structure.yml | 14 +++++++++++ 8 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 tests/types/result/family_subfamily/tiramisu.py create mode 100644 tests/types/result/family_subfamily/variables.json create mode 100644 tests/types/structures/family_subfamily/00_structure.yml create mode 100644 tests/types/structures/variable_hidden/00_structure.yml create mode 100644 tests/types/types/family_redefine/00_structure.yml create mode 100644 tests/types/types/family_subfamily/00_structure.yml create mode 100644 tests/types/types/variable_hidden/00_structure.yml diff --git a/src/rougail/types.py b/src/rougail/types.py index bff6f80b2..386f026ac 100644 --- a/src/rougail/types.py +++ b/src/rougail/types.py @@ -68,7 +68,7 @@ def to_dict_family(family_name, paths, parents, families, root=True): raise DictConsistencyError(_("type is not compatible with dynamic family"), variable.xmlfiles) if variable_name in ret: ret["_" + variable_name] = ret.pop(variable_name) - ret[variable_name] = to_dict_family(variable_name, paths, parents, families, False) + ret[variable_name] = to_dict_family(variable.path, paths, parents, families, False) else: ret[variable_name] = to_dict_variable(variable, False) return ret diff --git a/tests/types/result/family_subfamily/tiramisu.py b/tests/types/result/family_subfamily/tiramisu.py new file mode 100644 index 000000000..68f3548e7 --- /dev/null +++ b/tests/types/result/family_subfamily/tiramisu.py @@ -0,0 +1,25 @@ +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/family_subfamily/00_structure.yml', 'tests/types/structures/family_subfamily/00_structure.yml'], 'type': 'string'}) +option_5 = StrOption(name="a_second_variable", doc="a second variable", default="a modified value", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['tests/types/types/family_subfamily/00_structure.yml', 'tests/types/structures/family_subfamily/00_structure.yml'], 'type': 'string'}) +optiondescription_4 = OptionDescription(name="a_sub_family", doc="My subfamily", children=[option_5], properties=frozenset({"standard"}), informations={'ymlfiles': ['tests/types/types/family_subfamily/00_structure.yml', 'tests/types/structures/family_subfamily/00_structure.yml']}) +optiondescription_2 = OptionDescription(name="my_family_1", doc="My family type", children=[option_3, optiondescription_4], properties=frozenset({"standard"}), informations={'ymlfiles': ['tests/types/types/family_subfamily/00_structure.yml', 'tests/types/structures/family_subfamily/00_structure.yml']}) +option_7 = StrOption(name="a_first_variable", doc="a first variable", default="a value", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['tests/types/types/family_subfamily/00_structure.yml'], 'type': 'string'}) +option_9 = StrOption(name="a_second_variable", doc="a second variable", properties=frozenset({"basic", "mandatory"}), informations={'ymlfiles': ['tests/types/types/family_subfamily/00_structure.yml'], 'type': 'string'}) +optiondescription_8 = OptionDescription(name="a_sub_family", doc="My subfamily", children=[option_9], properties=frozenset({"basic"}), informations={'ymlfiles': ['tests/types/types/family_subfamily/00_structure.yml']}) +optiondescription_6 = OptionDescription(name="my_family_2", doc="My family type", children=[option_7, optiondescription_8], properties=frozenset({"basic"}), informations={'ymlfiles': ['tests/types/types/family_subfamily/00_structure.yml', 'tests/types/structures/family_subfamily/00_structure.yml']}) +option_11 = StrOption(name="a_first_variable", doc="a first variable", default="a value", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['tests/types/types/family_subfamily/00_structure.yml'], 'type': 'string'}) +option_13 = StrOption(name="a_second_variable", doc="a second variable", default="a modified value 2", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['tests/types/types/family_subfamily/00_structure.yml', 'tests/types/structures/family_subfamily/00_structure.yml'], 'type': 'string'}) +optiondescription_12 = OptionDescription(name="a_sub_family", doc="My subfamily", children=[option_13], properties=frozenset({"standard"}), informations={'ymlfiles': ['tests/types/types/family_subfamily/00_structure.yml', 'tests/types/structures/family_subfamily/00_structure.yml']}) +optiondescription_10 = OptionDescription(name="my_family_3", doc="My family type", children=[option_11, optiondescription_12], properties=frozenset({"standard"}), informations={'ymlfiles': ['tests/types/types/family_subfamily/00_structure.yml', 'tests/types/structures/family_subfamily/00_structure.yml']}) +optiondescription_1 = OptionDescription(name="rougail", doc="rougail", group_type=groups.namespace, children=[optiondescription_2, optiondescription_6, optiondescription_10], properties=frozenset({"basic"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/types/result/family_subfamily/variables.json b/tests/types/result/family_subfamily/variables.json new file mode 100644 index 000000000..76f7ca42d --- /dev/null +++ b/tests/types/result/family_subfamily/variables.json @@ -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" +} \ No newline at end of file diff --git a/tests/types/structures/family_subfamily/00_structure.yml b/tests/types/structures/family_subfamily/00_structure.yml new file mode 100644 index 000000000..63ba54826 --- /dev/null +++ b/tests/types/structures/family_subfamily/00_structure.yml @@ -0,0 +1,23 @@ +%YAML 1.2 +--- +version: 1.1 + +my_family_1: + type: my_family_type + + a_first_variable: a modified value + + a_sub_family: + + a_second_variable: a modified value + +my_family_2: + type: my_family_type + +my_family_3: + type: my_family_type + + a_sub_family: + + a_second_variable: a modified value 2 +... diff --git a/tests/types/structures/variable_hidden/00_structure.yml b/tests/types/structures/variable_hidden/00_structure.yml new file mode 100644 index 000000000..e412ca47e --- /dev/null +++ b/tests/types/structures/variable_hidden/00_structure.yml @@ -0,0 +1,19 @@ +%YAML 1.2 +--- +version: 1.1 + +my_family_1: + type: my_family_type + + a_first_variable: a modified value + + a_second_variable: a modified value + +my_family_2: + type: my_family_type + +my_family_3: + type: my_family_type + + a_second_variable: a modified value 2 +... diff --git a/tests/types/types/family_redefine/00_structure.yml b/tests/types/types/family_redefine/00_structure.yml new file mode 100644 index 000000000..79c52daeb --- /dev/null +++ b/tests/types/types/family_redefine/00_structure.yml @@ -0,0 +1,10 @@ +%YAML 1.2 +--- +version: 1.1 + +my_family_type: # My family type + + a_first_variable: a value # a first variable + + a_second_variable: # a second variable +... diff --git a/tests/types/types/family_subfamily/00_structure.yml b/tests/types/types/family_subfamily/00_structure.yml new file mode 100644 index 000000000..aa378b739 --- /dev/null +++ b/tests/types/types/family_subfamily/00_structure.yml @@ -0,0 +1,12 @@ +%YAML 1.2 +--- +version: 1.1 + +my_family_type: # My family type + + a_first_variable: a value # a first variable + + a_sub_family: # My subfamily + + a_second_variable: # a second variable +... diff --git a/tests/types/types/variable_hidden/00_structure.yml b/tests/types/types/variable_hidden/00_structure.yml new file mode 100644 index 000000000..edacbd84e --- /dev/null +++ b/tests/types/types/variable_hidden/00_structure.yml @@ -0,0 +1,14 @@ +%YAML 1.2 +--- +version: 1.1 + +my_family_type: # My family type + + a_first_variable: a value # a first variable + + a_second_variable: + description: a second variable + hidden: + variable: _.a_first_variable + when_not: a value +...