From a2c3a1bb3afe6a77725f14f3e93e81e18184fa83 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 22 Jun 2023 12:11:14 +0200 Subject: [PATCH] variable is add to information target --- doc/param/information.md | 44 ++++++++++++++---- src/rougail/annotator/param.py | 15 +++++++ src/rougail/data/rougail.dtd | 8 +++- src/rougail/data/rougail.yml | 45 ++++++++++++++----- .../10fill_option_information/__init__.py | 0 .../informations.json | 1 + .../makedict/after.json | 10 +++++ .../makedict/base.json | 4 ++ .../makedict/before.json | 10 +++++ .../tiramisu/multi.py | 4 +- .../10fill_option_information/xml/00-base.xml | 15 +++++++ .../10fill_option_information/yml/00-base.yml | 21 +++++++++ .../10fill_option_od_information/__init__.py | 0 .../informations.json | 1 + .../makedict/after.json | 10 +++++ .../makedict/base.json | 4 ++ .../makedict/before.json | 10 +++++ .../tiramisu/multi.py | 4 +- .../xml/00-base.xml | 17 +++++++ .../yml/00-base.yml | 25 +++++++++++ .../10fill_target_information/__init__.py | 0 .../informations.json | 1 + .../makedict/after.json | 6 +++ .../makedict/base.json | 3 ++ .../makedict/before.json | 6 +++ .../10fill_target_information/xml/00-base.xml | 14 ++++++ .../10fill_target_information/yml/00-base.yml | 18 ++++++++ tests/dictionaries/80fill_option/__init__.py | 0 tests/dictionaries/80fill_option/errno_90 | 0 .../80fill_option/xml/00-base.xml | 17 +++++++ .../80fill_option/yml/00-base.yml | 23 ++++++++++ tests/test_2_makedict.py | 22 ++++++--- tests/test_3_template.py | 6 +-- 33 files changed, 329 insertions(+), 35 deletions(-) create mode 100644 tests/dictionaries/10fill_option_information/__init__.py create mode 100644 tests/dictionaries/10fill_option_information/informations.json create mode 100644 tests/dictionaries/10fill_option_information/makedict/after.json create mode 100644 tests/dictionaries/10fill_option_information/makedict/base.json create mode 100644 tests/dictionaries/10fill_option_information/makedict/before.json create mode 100644 tests/dictionaries/10fill_option_information/xml/00-base.xml create mode 100644 tests/dictionaries/10fill_option_information/yml/00-base.yml create mode 100644 tests/dictionaries/10fill_option_od_information/__init__.py create mode 100644 tests/dictionaries/10fill_option_od_information/informations.json create mode 100644 tests/dictionaries/10fill_option_od_information/makedict/after.json create mode 100644 tests/dictionaries/10fill_option_od_information/makedict/base.json create mode 100644 tests/dictionaries/10fill_option_od_information/makedict/before.json create mode 100644 tests/dictionaries/10fill_option_od_information/xml/00-base.xml create mode 100644 tests/dictionaries/10fill_option_od_information/yml/00-base.yml create mode 100644 tests/dictionaries/10fill_target_information/__init__.py create mode 100644 tests/dictionaries/10fill_target_information/informations.json create mode 100644 tests/dictionaries/10fill_target_information/makedict/after.json create mode 100644 tests/dictionaries/10fill_target_information/makedict/base.json create mode 100644 tests/dictionaries/10fill_target_information/makedict/before.json create mode 100644 tests/dictionaries/10fill_target_information/xml/00-base.xml create mode 100644 tests/dictionaries/10fill_target_information/yml/00-base.yml create mode 100644 tests/dictionaries/80fill_option/__init__.py create mode 100644 tests/dictionaries/80fill_option/errno_90 create mode 100644 tests/dictionaries/80fill_option/xml/00-base.xml create mode 100644 tests/dictionaries/80fill_option/yml/00-base.yml diff --git a/doc/param/information.md b/doc/param/information.md index 2afc86568..450deb9e3 100644 --- a/doc/param/information.md +++ b/doc/param/information.md @@ -17,26 +17,52 @@ param: ``` Dans ce cas, l'information de la configuration "server_name" sera utilisé comme valeur du paramètre. -Si l'information n'existe pas, la paramètre aura la valeur "None". +Si l'information n'existe pas, la paramètre aura la valeur "None" ou [] pour une variable multiple. -## Les informations de la cible +## Les informations d'une variable -Le paramètre peut être la valeur est issue d'une information de la cible du calcul : +Le paramètre peut être la valeur est issue d'une information d'une variable : ```xml -test -help +test +help ``` En YAML : ```yml param: -- type: target_information +- type: information + variable: a_variable text: test -- type: target_information +- type: information + variable: a_variable text: help ``` -Dans ce cas, l'information de la configuration "test" ou "help" sera utilisé comme valeur du paramètre. -Si l'information n'existe pas, la paramètre aura la valeur "None". +Dans ce cas, l'information de la variable "a_variable" "test" ou "help" sera utilisée comme valeur du paramètre. +Si l'information n'existe pas, la paramètre aura la valeur "None" ou [] pour une variable multiple. + +## Les informations de la cible + +Le paramètre peut être la valeur est issue d'une information de la cible du calcul (la target) : + +```xml +test +help +``` + +En YAML : + +```yml +param: +- type: information + variable: target_variable + text: test +- type: information + variable: target_variable + text: help +``` + +Dans ce cas, l'information de la variable de la cible (target_variable) "test" ou "help" sera utilisée comme valeur du paramètre. +Si l'information n'existe pas, la paramètre aura la valeur "None" ou [] pour une variable multiple. diff --git a/src/rougail/annotator/param.py b/src/rougail/annotator/param.py index 56baf8c23..74b3a1dfa 100644 --- a/src/rougail/annotator/param.py +++ b/src/rougail/annotator/param.py @@ -62,6 +62,9 @@ class ParamAnnotator: if param.type in ['suffix', 'index']: msg = _(f'"{param.type}" parameter must not have a value') raise DictConsistencyError(msg, 28, obj.xmlfiles) + if param.type != 'information' and hasattr(param, 'variable'): + msg = _(f'"{param.type}" parameter must not have variable attribut') + raise DictConsistencyError(msg, 90, obj.xmlfiles) if param.type in ['nil', 'space']: if param.text is not None: msg = _(f'"{param.type}" parameter must not have a value') @@ -103,6 +106,18 @@ class ParamAnnotator: if param_idx != 0: msg = _(f'function "{param.text}" must only set has first parameter') raise DictConsistencyError(msg, 75, param.xmlfiles) + elif param.type == 'information': + if hasattr(param, 'variable'): + try: + param.variable = self.objectspace.paths.get_family(param.variable, + current_namespace=obj.namespace, + path_prefix=path_prefix, + ) + except DictConsistencyError: + param.variable = self.objectspace.paths.get_variable(param.variable, + namespace=obj.namespace, + force_path_prefix=path_prefix, + ) elif variable_type: self._convert_with_variable_type(variable_type, param) continue diff --git a/src/rougail/data/rougail.dtd b/src/rougail/data/rougail.dtd index 5da314b0d..db5028975 100644 --- a/src/rougail/data/rougail.dtd +++ b/src/rougail/data/rougail.dtd @@ -92,6 +92,8 @@ + + @@ -101,6 +103,7 @@ + @@ -160,11 +163,12 @@ - + + - + diff --git a/src/rougail/data/rougail.yml b/src/rougail/data/rougail.yml index 66476dc45..d418e1c6b 100644 --- a/src/rougail/data/rougail.yml +++ b/src/rougail/data/rougail.yml @@ -114,6 +114,8 @@ mapping: enum: - "string" - "variable" + certificatelist: + type: str redefine: type: bool type: @@ -144,6 +146,13 @@ mapping: - "variable" server: type: str + group_type: + type: str + enum: + - "unix_user" + - "variable" + group: + type: str owner_type: type: str enum: @@ -215,13 +224,14 @@ mapping: - "variable" - "function" - "information" - - "target_information" - "suffix" - "index" optional: type: bool propertyerror: type: bool + variable: + type: str name: type: str type: @@ -361,13 +371,14 @@ mapping: - "variable" - "function" - "information" - - "target_information" - "suffix" - "index" optional: type: bool propertyerror: type: bool + variable: + type: str name: type: str type: @@ -508,13 +519,14 @@ mapping: - "variable" - "function" - "information" - - "target_information" - "suffix" - "index" optional: type: bool propertyerror: type: bool + variable: + type: str name: type: str type: @@ -687,13 +699,14 @@ mapping: - "variable" - "function" - "information" - - "target_information" - "suffix" - "index" optional: type: bool propertyerror: type: bool + variable: + type: str name: type: str type: @@ -833,13 +846,14 @@ mapping: - "variable" - "function" - "information" - - "target_information" - "suffix" - "index" optional: type: bool propertyerror: type: bool + variable: + type: str name: type: str type: @@ -996,13 +1010,14 @@ mapping: - "variable" - "function" - "information" - - "target_information" - "suffix" - "index" optional: type: bool propertyerror: type: bool + variable: + type: str name: type: str type: @@ -1142,13 +1157,14 @@ mapping: - "variable" - "function" - "information" - - "target_information" - "suffix" - "index" optional: type: bool propertyerror: type: bool + variable: + type: str name: type: str type: @@ -1305,13 +1321,14 @@ mapping: - "variable" - "function" - "information" - - "target_information" - "suffix" - "index" optional: type: bool propertyerror: type: bool + variable: + type: str name: type: str type: @@ -1440,6 +1457,7 @@ mapping: - "servicelist" - "filelist" - "iplist" + - "certificatelist" optional: type: bool param: @@ -1462,13 +1480,14 @@ mapping: - "variable" - "function" - "information" - - "target_information" - "suffix" - "index" optional: type: bool propertyerror: type: bool + variable: + type: str name: type: str name: @@ -1496,6 +1515,7 @@ mapping: - "servicelist" - "filelist" - "iplist" + - "certificatelist" optional: type: bool param: @@ -1518,13 +1538,14 @@ mapping: - "variable" - "function" - "information" - - "target_information" - "suffix" - "index" optional: type: bool propertyerror: type: bool + variable: + type: str name: type: str name: @@ -1557,6 +1578,7 @@ mapping: - "servicelist" - "filelist" - "iplist" + - "certificatelist" optional: type: bool param: @@ -1579,13 +1601,14 @@ mapping: - "variable" - "function" - "information" - - "target_information" - "suffix" - "index" optional: type: bool propertyerror: type: bool + variable: + type: str name: type: str name: diff --git a/tests/dictionaries/10fill_option_information/__init__.py b/tests/dictionaries/10fill_option_information/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/10fill_option_information/informations.json b/tests/dictionaries/10fill_option_information/informations.json new file mode 100644 index 000000000..69510fc75 --- /dev/null +++ b/tests/dictionaries/10fill_option_information/informations.json @@ -0,0 +1 @@ +{"rougail.general.variable": "value"} diff --git a/tests/dictionaries/10fill_option_information/makedict/after.json b/tests/dictionaries/10fill_option_information/makedict/after.json new file mode 100644 index 000000000..7f08ef4fb --- /dev/null +++ b/tests/dictionaries/10fill_option_information/makedict/after.json @@ -0,0 +1,10 @@ +{ + "rougail.general.variable": { + "owner": "default", + "value": null + }, + "rougail.general.mode_conteneur_actif": { + "owner": "default", + "value": "value" + } +} diff --git a/tests/dictionaries/10fill_option_information/makedict/base.json b/tests/dictionaries/10fill_option_information/makedict/base.json new file mode 100644 index 000000000..bd4b110e3 --- /dev/null +++ b/tests/dictionaries/10fill_option_information/makedict/base.json @@ -0,0 +1,4 @@ +{ + "rougail.general.variable": null, + "rougail.general.mode_conteneur_actif": "value" +} diff --git a/tests/dictionaries/10fill_option_information/makedict/before.json b/tests/dictionaries/10fill_option_information/makedict/before.json new file mode 100644 index 000000000..7f08ef4fb --- /dev/null +++ b/tests/dictionaries/10fill_option_information/makedict/before.json @@ -0,0 +1,10 @@ +{ + "rougail.general.variable": { + "owner": "default", + "value": null + }, + "rougail.general.mode_conteneur_actif": { + "owner": "default", + "value": "value" + } +} diff --git a/tests/dictionaries/10fill_option_information/tiramisu/multi.py b/tests/dictionaries/10fill_option_information/tiramisu/multi.py index 8844e8728..73d10f6d8 100644 --- a/tests/dictionaries/10fill_option_information/tiramisu/multi.py +++ b/tests/dictionaries/10fill_option_information/tiramisu/multi.py @@ -19,11 +19,11 @@ try: except: from tiramisu import * option_2 = StrOption(name="variable", doc="No change", properties=frozenset({"normal"})) -option_5 = StrOption(name="variable", doc="No change", properties=frozenset({"normal"})) -option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.calc_val, Params((ParamInformation("test_information", None, option=option_5)))), properties=frozenset({"normal"})) +option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.calc_val, Params((ParamInformation("test_information", None, option=option_2)))), properties=frozenset({"normal"})) optiondescription_1 = OptionDescription(name="general", doc="general", children=[option_2, option_3], properties=frozenset({"normal"})) optiondescription_8 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_1]) optiondescription_7 = OptionDescription(name="1", doc="1", children=[optiondescription_8]) +option_5 = StrOption(name="variable", doc="No change", properties=frozenset({"normal"})) option_6 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.calc_val, Params((ParamInformation("test_information", None, option=option_5)))), properties=frozenset({"normal"})) optiondescription_4 = OptionDescription(name="general", doc="general", children=[option_5, option_6], properties=frozenset({"normal"})) optiondescription_10 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_4]) diff --git a/tests/dictionaries/10fill_option_information/xml/00-base.xml b/tests/dictionaries/10fill_option_information/xml/00-base.xml new file mode 100644 index 000000000..dea77acb7 --- /dev/null +++ b/tests/dictionaries/10fill_option_information/xml/00-base.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + test_information + mode_conteneur_actif + + + diff --git a/tests/dictionaries/10fill_option_information/yml/00-base.yml b/tests/dictionaries/10fill_option_information/yml/00-base.yml new file mode 100644 index 000000000..93fa798a3 --- /dev/null +++ b/tests/dictionaries/10fill_option_information/yml/00-base.yml @@ -0,0 +1,21 @@ +version: '0.10' +variables: +- family: + - name: general + variables: + - variable: + - name: variable + type: string + description: No change + - name: mode_conteneur_actif + type: string + description: No change +constraints: +- fill: + - name: calc_val + param: + - type: information + variable: variable + text: test_information + target: + - text: mode_conteneur_actif diff --git a/tests/dictionaries/10fill_option_od_information/__init__.py b/tests/dictionaries/10fill_option_od_information/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/10fill_option_od_information/informations.json b/tests/dictionaries/10fill_option_od_information/informations.json new file mode 100644 index 000000000..8969341e5 --- /dev/null +++ b/tests/dictionaries/10fill_option_od_information/informations.json @@ -0,0 +1 @@ +{"rougail.general.od": "value"} diff --git a/tests/dictionaries/10fill_option_od_information/makedict/after.json b/tests/dictionaries/10fill_option_od_information/makedict/after.json new file mode 100644 index 000000000..ab35e5934 --- /dev/null +++ b/tests/dictionaries/10fill_option_od_information/makedict/after.json @@ -0,0 +1,10 @@ +{ + "rougail.general.mode_conteneur_actif": { + "owner": "default", + "value": null + }, + "rougail.general.od.variable": { + "owner": "default", + "value": null + } +} diff --git a/tests/dictionaries/10fill_option_od_information/makedict/base.json b/tests/dictionaries/10fill_option_od_information/makedict/base.json new file mode 100644 index 000000000..2823ac4e3 --- /dev/null +++ b/tests/dictionaries/10fill_option_od_information/makedict/base.json @@ -0,0 +1,4 @@ +{ + "rougail.general.mode_conteneur_actif": null, + "rougail.general.od.variable": null +} diff --git a/tests/dictionaries/10fill_option_od_information/makedict/before.json b/tests/dictionaries/10fill_option_od_information/makedict/before.json new file mode 100644 index 000000000..ab35e5934 --- /dev/null +++ b/tests/dictionaries/10fill_option_od_information/makedict/before.json @@ -0,0 +1,10 @@ +{ + "rougail.general.mode_conteneur_actif": { + "owner": "default", + "value": null + }, + "rougail.general.od.variable": { + "owner": "default", + "value": null + } +} diff --git a/tests/dictionaries/10fill_option_od_information/tiramisu/multi.py b/tests/dictionaries/10fill_option_od_information/tiramisu/multi.py index 5890796e7..ff5d7d5a7 100644 --- a/tests/dictionaries/10fill_option_od_information/tiramisu/multi.py +++ b/tests/dictionaries/10fill_option_od_information/tiramisu/multi.py @@ -18,13 +18,13 @@ try: from tiramisu4 import * except: from tiramisu import * -option_8 = StrOption(name="variable", doc="No change", properties=frozenset({"normal"})) -option_2 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.calc_val, Params((ParamInformation("test_information", None, option=option_8)))), properties=frozenset({"normal"})) option_4 = StrOption(name="variable", doc="No change", properties=frozenset({"normal"})) +option_2 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.calc_val, Params((ParamInformation("test_information", None, option=option_4)))), properties=frozenset({"normal"})) optiondescription_3 = OptionDescription(name="od", doc="od", children=[option_4], properties=frozenset({"normal"})) optiondescription_1 = OptionDescription(name="general", doc="general", children=[option_2, optiondescription_3], properties=frozenset({"normal"})) optiondescription_10 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_1]) optiondescription_9 = OptionDescription(name="1", doc="1", children=[optiondescription_10]) +option_8 = StrOption(name="variable", doc="No change", properties=frozenset({"normal"})) option_6 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.calc_val, Params((ParamInformation("test_information", None, option=option_8)))), properties=frozenset({"normal"})) optiondescription_7 = OptionDescription(name="od", doc="od", children=[option_8], properties=frozenset({"normal"})) optiondescription_5 = OptionDescription(name="general", doc="general", children=[option_6, optiondescription_7], properties=frozenset({"normal"})) diff --git a/tests/dictionaries/10fill_option_od_information/xml/00-base.xml b/tests/dictionaries/10fill_option_od_information/xml/00-base.xml new file mode 100644 index 000000000..adfe0487c --- /dev/null +++ b/tests/dictionaries/10fill_option_od_information/xml/00-base.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + test_information + mode_conteneur_actif + + + diff --git a/tests/dictionaries/10fill_option_od_information/yml/00-base.yml b/tests/dictionaries/10fill_option_od_information/yml/00-base.yml new file mode 100644 index 000000000..6b601f256 --- /dev/null +++ b/tests/dictionaries/10fill_option_od_information/yml/00-base.yml @@ -0,0 +1,25 @@ +version: '0.10' +variables: +- family: + - name: general + variables: + - variable: + - name: mode_conteneur_actif + type: string + description: No change + - family: + - name: od + variables: + - variable: + - name: variable + type: string + description: No change +constraints: +- fill: + - name: calc_val + param: + - type: information + variable: variable + text: test_information + target: + - text: mode_conteneur_actif diff --git a/tests/dictionaries/10fill_target_information/__init__.py b/tests/dictionaries/10fill_target_information/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/10fill_target_information/informations.json b/tests/dictionaries/10fill_target_information/informations.json new file mode 100644 index 000000000..5f62f349f --- /dev/null +++ b/tests/dictionaries/10fill_target_information/informations.json @@ -0,0 +1 @@ +{"rougail.general.mode_conteneur_actif": "value"} diff --git a/tests/dictionaries/10fill_target_information/makedict/after.json b/tests/dictionaries/10fill_target_information/makedict/after.json new file mode 100644 index 000000000..6f4a21e7d --- /dev/null +++ b/tests/dictionaries/10fill_target_information/makedict/after.json @@ -0,0 +1,6 @@ +{ + "rougail.general.mode_conteneur_actif": { + "owner": "default", + "value": "value" + } +} diff --git a/tests/dictionaries/10fill_target_information/makedict/base.json b/tests/dictionaries/10fill_target_information/makedict/base.json new file mode 100644 index 000000000..904ffb4eb --- /dev/null +++ b/tests/dictionaries/10fill_target_information/makedict/base.json @@ -0,0 +1,3 @@ +{ + "rougail.general.mode_conteneur_actif": "value" +} diff --git a/tests/dictionaries/10fill_target_information/makedict/before.json b/tests/dictionaries/10fill_target_information/makedict/before.json new file mode 100644 index 000000000..6f4a21e7d --- /dev/null +++ b/tests/dictionaries/10fill_target_information/makedict/before.json @@ -0,0 +1,6 @@ +{ + "rougail.general.mode_conteneur_actif": { + "owner": "default", + "value": "value" + } +} diff --git a/tests/dictionaries/10fill_target_information/xml/00-base.xml b/tests/dictionaries/10fill_target_information/xml/00-base.xml new file mode 100644 index 000000000..c79e7efad --- /dev/null +++ b/tests/dictionaries/10fill_target_information/xml/00-base.xml @@ -0,0 +1,14 @@ + + + + + + + + + + test_information + mode_conteneur_actif + + + diff --git a/tests/dictionaries/10fill_target_information/yml/00-base.yml b/tests/dictionaries/10fill_target_information/yml/00-base.yml new file mode 100644 index 000000000..99d3e7335 --- /dev/null +++ b/tests/dictionaries/10fill_target_information/yml/00-base.yml @@ -0,0 +1,18 @@ +version: '0.10' +variables: +- family: + - name: general + variables: + - variable: + - name: mode_conteneur_actif + type: string + description: No change +constraints: +- fill: + - name: calc_val + param: + - type: information + variable: mode_conteneur_actif + text: test_information + target: + - text: mode_conteneur_actif diff --git a/tests/dictionaries/80fill_option/__init__.py b/tests/dictionaries/80fill_option/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/80fill_option/errno_90 b/tests/dictionaries/80fill_option/errno_90 new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/80fill_option/xml/00-base.xml b/tests/dictionaries/80fill_option/xml/00-base.xml new file mode 100644 index 000000000..25bba3d9b --- /dev/null +++ b/tests/dictionaries/80fill_option/xml/00-base.xml @@ -0,0 +1,17 @@ + + + + + + + non + + + + + + mode_conteneur_actif1 + mode_conteneur_actif + + + diff --git a/tests/dictionaries/80fill_option/yml/00-base.yml b/tests/dictionaries/80fill_option/yml/00-base.yml new file mode 100644 index 000000000..5b0453fe8 --- /dev/null +++ b/tests/dictionaries/80fill_option/yml/00-base.yml @@ -0,0 +1,23 @@ +version: '0.10' +variables: +- family: + - name: general + variables: + - variable: + - name: mode_conteneur_actif + type: string + description: No change + - name: mode_conteneur_actif1 + type: string + description: No change + value: + - text: non +constraints: +- fill: + - name: calc_val + param: + - type: variable + variable: mode_conteneur_actif1 + text: mode_conteneur_actif1 + target: + - text: mode_conteneur_actif diff --git a/tests/test_2_makedict.py b/tests/test_2_makedict.py index 3867c4f71..8ef8460d8 100644 --- a/tests/test_2_makedict.py +++ b/tests/test_2_makedict.py @@ -44,6 +44,7 @@ def launch_flattener(test_dir, makedict_file = join(makedict_dir, 'base.json') makedict_before = join(makedict_dir, 'before.json') makedict_after = join(makedict_dir, 'after.json') + informations_file = join(test_dir, 'informations.json') modulepath = test_dir.replace('/', '.') + f'.tiramisu.{filename}' mod = __import__(modulepath) @@ -51,9 +52,9 @@ def launch_flattener(test_dir, mod = getattr(mod, token) config = Config(mod.option_0) # change default rights - ro_origin = config.property.getdefault('read_only', 'append') + ro_origin = config.property.default('read_only', 'append') ro_append = frozenset(ro_origin - {'force_store_value'}) - rw_origin = config.property.getdefault('read_write', 'append') + rw_origin = config.property.default('read_write', 'append') rw_append = frozenset(rw_origin - {'force_store_value'}) config.property.setdefault(ro_append, 'read_only', 'append') config.property.setdefault(rw_append, 'read_write', 'append') @@ -62,6 +63,15 @@ def launch_flattener(test_dir, config.property.read_only() config.property.remove('mandatory') config.information.set('info', 'value') + if isfile(informations_file): + with open(informations_file) as informations: + for key, value in load(informations).items(): + if filename == 'base': + config.option(key).information.set('test_information', value) + else: + for root in ['1', '2']: + config.option(f'{root}.{key}').information.set('test_information', value) + # config_dict = config.value.dict() if filename == 'base': if not isdir(makedict_dir): @@ -93,10 +103,10 @@ def launch_flattener(test_dir, # value_owner(makedict_before, config, filename) # deploy - ro = config.property.getdefault('read_only', 'append') + ro = config.property.default('read_only', 'append') ro = frozenset(list(ro) + ['force_store_value']) config.property.setdefault(ro, 'read_only', 'append') - rw = config.property.getdefault('read_write', 'append') + rw = config.property.default('read_write', 'append') rw = frozenset(list(rw) + ['force_store_value']) config.property.setdefault(rw, 'read_write', 'append') config.property.add('force_store_value') @@ -107,8 +117,8 @@ def launch_flattener(test_dir, def value_owner(makedict_value_owner, config, filename): ret = {} for key in config.option.list(recursive=True): - path = key.option.path() - if not key.option.issymlinkoption() and key.option.isfollower(): + path = key.path() + if not key.issymlinkoption() and key.isfollower(): value = [] owner = [] for idx in range(0, key.value.len()): diff --git a/tests/test_3_template.py b/tests/test_3_template.py index f813fce35..b6b15e485 100644 --- a/tests/test_3_template.py +++ b/tests/test_3_template.py @@ -103,7 +103,7 @@ def templates(test_dir, filename, root, engine_name, only_one=False): included = False activate = True for service in config.option('services').list('all'): - names = [o.option.name() for o in service.list('optiondescription')] + names = [o.name() for o in service.list('optiondescription')] if 'files' in names: for file in service.option('files').list('optiondescription'): if not file.option('source').value.get() == template: @@ -120,10 +120,10 @@ def templates(test_dir, filename, root, engine_name, only_one=False): # if template is an overrides if not list_results and 'overrides' in names: for override in service.option('overrides').list('optiondescription'): - if override.option.description() == template: + if override.description() == template: return # if template is a service - if not list_results and template == service.option.description() and service.information.get('engine', None): + if not list_results and template == service.description() and service.information.get('engine', None): return #this file is include and not declared if template.startswith('inc') and not list_results: