variable is add to information target

This commit is contained in:
egarette@silique.fr 2023-06-22 12:11:14 +02:00
parent 764390d8ca
commit a2c3a1bb3a
33 changed files with 329 additions and 35 deletions

View file

@ -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
<param type="target_information">test</param>
<param type="target_information">help</param>
<param type="information" variable="a_variable">test</param>
<param type="information" variable="a_variable">help</param>
```
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
<param type="information" variable="target_variable">test</param>
<param type="information" variable="target_variable">help</param>
```
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.

View file

@ -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

View file

@ -92,6 +92,8 @@
<!ATTLIST certificate authority CDATA #REQUIRED>
<!ATTLIST certificate owner CDATA #IMPLIED>
<!ATTLIST certificate owner_type (unix_user|variable) "unix_user">
<!ATTLIST certificate group CDATA #IMPLIED>
<!ATTLIST certificate group_type (unix_user|variable) "unix_user">
<!ATTLIST certificate server CDATA #IMPLIED>
<!ATTLIST certificate server_type (variable) "variable">
<!ATTLIST certificate domain CDATA #IMPLIED>
@ -101,6 +103,7 @@
<!ATTLIST certificate format (cert_key|pem) "cert_key">
<!ATTLIST certificate type (client|server) "client">
<!ATTLIST certificate redefine (True|False) "False">
<!ATTLIST certificate certificatelist CDATA #IMPLIED>
<!ELEMENT variables ((variable*|family*)*)>
@ -160,11 +163,12 @@
<!ATTLIST condition apply_on_fallback (True|False) #IMPLIED>
<!ELEMENT param (#PCDATA)>
<!ATTLIST param type (string|number|nil|space|boolean|variable|function|information|target_information|suffix|index) "string">
<!ATTLIST param type (string|number|nil|space|boolean|variable|function|information|suffix|index) "string">
<!ATTLIST param name CDATA #IMPLIED>
<!ATTLIST param variable CDATA #IMPLIED>
<!ATTLIST param propertyerror (True|False) "True">
<!ATTLIST param optional (True|False) "False">
<!ELEMENT target (#PCDATA)>
<!ATTLIST target type (variable|family|servicelist|filelist|iplist) "variable">
<!ATTLIST target type (variable|family|servicelist|filelist|iplist|certificatelist) "variable">
<!ATTLIST target optional (True|False) "False">

View file

@ -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:

View file

@ -0,0 +1 @@
{"rougail.general.variable": "value"}

View file

@ -0,0 +1,10 @@
{
"rougail.general.variable": {
"owner": "default",
"value": null
},
"rougail.general.mode_conteneur_actif": {
"owner": "default",
"value": "value"
}
}

View file

@ -0,0 +1,4 @@
{
"rougail.general.variable": null,
"rougail.general.mode_conteneur_actif": "value"
}

View file

@ -0,0 +1,10 @@
{
"rougail.general.variable": {
"owner": "default",
"value": null
},
"rougail.general.mode_conteneur_actif": {
"owner": "default",
"value": "value"
}
}

View file

@ -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])

View file

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<family name="general">
<variable name="variable" type="string" description="No change"/>
<variable name="mode_conteneur_actif" type="string" description="No change"/>
</family>
</variables>
<constraints>
<fill name="calc_val">
<param type="information" variable="variable">test_information</param>
<target>mode_conteneur_actif</target>
</fill>
</constraints>
</rougail>

View file

@ -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

View file

@ -0,0 +1 @@
{"rougail.general.od": "value"}

View file

@ -0,0 +1,10 @@
{
"rougail.general.mode_conteneur_actif": {
"owner": "default",
"value": null
},
"rougail.general.od.variable": {
"owner": "default",
"value": null
}
}

View file

@ -0,0 +1,4 @@
{
"rougail.general.mode_conteneur_actif": null,
"rougail.general.od.variable": null
}

View file

@ -0,0 +1,10 @@
{
"rougail.general.mode_conteneur_actif": {
"owner": "default",
"value": null
},
"rougail.general.od.variable": {
"owner": "default",
"value": null
}
}

View file

@ -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"}))

View file

@ -0,0 +1,17 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change"/>
<family name="od">
<variable name="variable" type="string" description="No change"/>
</family>
</family>
</variables>
<constraints>
<fill name="calc_val">
<param type="information" variable="variable">test_information</param>
<target>mode_conteneur_actif</target>
</fill>
</constraints>
</rougail>

View file

@ -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

View file

@ -0,0 +1 @@
{"rougail.general.mode_conteneur_actif": "value"}

View file

@ -0,0 +1,6 @@
{
"rougail.general.mode_conteneur_actif": {
"owner": "default",
"value": "value"
}
}

View file

@ -0,0 +1,3 @@
{
"rougail.general.mode_conteneur_actif": "value"
}

View file

@ -0,0 +1,6 @@
{
"rougail.general.mode_conteneur_actif": {
"owner": "default",
"value": "value"
}
}

View file

@ -0,0 +1,14 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change"/>
</family>
</variables>
<constraints>
<fill name="calc_val">
<param type="information" variable="mode_conteneur_actif">test_information</param>
<target>mode_conteneur_actif</target>
</fill>
</constraints>
</rougail>

View file

@ -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

View file

@ -0,0 +1,17 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change"/>
<variable name="mode_conteneur_actif1" type="string" description="No change">
<value>non</value>
</variable>
</family>
</variables>
<constraints>
<fill name="calc_val">
<param type="variable" variable="mode_conteneur_actif1">mode_conteneur_actif1</param>
<target>mode_conteneur_actif</target>
</fill>
</constraints>
</rougail>

View file

@ -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

View file

@ -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()):

View file

@ -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: