Compare commits

..

6 Commits

62 changed files with 559 additions and 85 deletions

View File

@ -126,7 +126,8 @@ class ConstrainteAnnotator:
xmlfiles = self.objectspace.display_xmlfiles(check.xmlfiles)
raise DictConsistencyError(_(f'valid_enum define in {xmlfiles} but already set in {old_xmlfiles} for "{check.target}", did you forget remove_check?'), 3)
if not hasattr(check, 'param'):
raise DictConsistencyError(_(f'param is mandatory for a valid_enum of variable {check.target}'), 4)
xmlfiles = self.objectspace.display_xmlfiles(check.xmlfiles)
raise DictConsistencyError(_(f'param is mandatory for a valid_enum of variable "{check.target}" in {xmlfiles}'), 4)
variable = self.objectspace.paths.get_variable_obj(check.target)
values = self.load_params_in_valid_enum(check.param,
variable.name,
@ -153,18 +154,22 @@ class ConstrainteAnnotator:
for param in params:
if param.type == 'variable':
if has_variable is not None:
raise DictConsistencyError(_(f'only one "variable" parameter is allowed for valid_enum of variable {variable_name}'), 5)
xmlfiles = self.objectspace.display_xmlfiles(param.xmlfiles)
raise DictConsistencyError(_(f'only one "variable" parameter is allowed for valid_enum of variable "{variable_name}" in {xmlfiles}'), 5)
has_variable = True
variable = self.objectspace.paths.get_variable_obj(param.text)
if not variable.multi:
raise DictConsistencyError(_(f'only multi "variable" parameter is allowed for valid_enum of variable {variable_name}'), 6)
xmlfiles = self.objectspace.display_xmlfiles(param.xmlfiles)
raise DictConsistencyError(_(f'only multi "variable" parameter is allowed for valid_enum of variable "{variable_name}" in {xmlfiles}'), 6)
values = param.text
else:
if has_variable:
raise DictConsistencyError(_(f'only one "variable" parameter is allowed for valid_enum of variable {variable_name}'), 7)
xmlfiles = self.objectspace.display_xmlfiles(param.xmlfiles)
raise DictConsistencyError(_(f'only one parameter is allowed for valid_enum of variable "{variable_name}" in {xmlfiles}'), 7)
if not hasattr(param, 'text'):
if param.type == 'number':
raise DictConsistencyError(_(f'value is mandatory for valid_enum of variable {variable_name}'), 8)
xmlfiles = self.objectspace.display_xmlfiles(param.xmlfiles)
raise DictConsistencyError(_(f'param type is number, so value is mandatory for valid_enum of variable "{variable_name}" in {xmlfiles}'), 8)
values.append(None)
else:
values.append(param.text)
@ -396,7 +401,7 @@ class ConstrainteAnnotator:
# build choice
variable.choice = []
if isinstance(values, str):
choice = self.objectspace.choice()
choice = self.objectspace.choice(variable.xmlfiles)
choice.type = 'calculation'
choice.name = values
variable.choice.append(choice)
@ -504,7 +509,8 @@ class ConstrainteAnnotator:
targets.append(fill.target)
#
if fill.name not in self.functions:
raise DictConsistencyError(_('cannot find fill function {}').format(fill.name), 25)
xmlfiles = self.objectspace.display_xmlfiles(fill.xmlfiles)
raise DictConsistencyError(_(f'cannot find fill function {fill.name} in {xmlfiles}'), 25)
namespace = fill.namespace
# let's replace the target by the path
@ -513,7 +519,8 @@ class ConstrainteAnnotator:
with_suffix=True,
)
if suffix is not None:
raise DictConsistencyError(_(f'Cannot add fill function to "{fill.target}" only with the suffix "{suffix}"'), 26)
xmlfiles = self.objectspace.display_xmlfiles(fill.xmlfiles)
raise DictConsistencyError(_(f'Cannot add fill function to "{fill.target}" only with the suffix "{suffix}" in {xmlfiles}'), 26)
variable = self.objectspace.paths.get_variable_obj(fill.target)
value = self.objectspace.value(variable.xmlfiles)
value.type = 'calculation'
@ -522,9 +529,15 @@ class ConstrainteAnnotator:
param_to_delete = []
for fill_idx, param in enumerate(fill.param):
if param.type not in ['suffix', 'string'] and not hasattr(param, 'text'):
raise DictConsistencyError(_(f"All '{param.type}' variables must have a value in order to calculate {fill.target}"), 27)
if param.type == 'suffix' and hasattr(param, 'text'):
raise DictConsistencyError(_(f"All '{param.type}' variables must not have a value in order to calculate {fill.target}"), 28)
xmlfiles = self.objectspace.display_xmlfiles(fill.xmlfiles)
raise DictConsistencyError(_(f"All '{param.type}' variables must have a value in order to calculate {fill.target} in {xmlfiles}"), 27)
if param.type == 'suffix':
if hasattr(param, 'text'):
xmlfiles = self.objectspace.display_xmlfiles(fill.xmlfiles)
raise DictConsistencyError(_(f"All '{param.type}' variables must not have a value in order to calculate {fill.target} in {xmlfiles}"), 28)
if not self.objectspace.paths.variable_is_dynamic(fill.target):
xmlfiles = self.objectspace.display_xmlfiles(fill.xmlfiles)
raise DictConsistencyError(_(f'Cannot set suffix target to the none dynamic variable "{fill.target}" in {xmlfiles}'), 53)
if param.type == 'string':
if not hasattr(param, 'text'):
param.text = None

View File

@ -174,6 +174,11 @@ class Path:
return True
return name in self.variables
def variable_is_dynamic(self,
name: str,
) -> bool:
return self._get_variable(name)['is_dynamic']
def _get_variable(self,
name: str,
with_suffix: bool=False,

View File

@ -44,9 +44,7 @@ class TiramisuReflector:
)
def get_root_family(self):
family = Family(BaseElt('baseoption',
'baseoption',
),
family = Family(BaseElt(),
self.storage,
False,
'.',
@ -158,15 +156,9 @@ class TiramisuReflector:
class BaseElt:
def __init__(self,
name,
doc,
):
self.name = name
self.doc = doc
def __iter__(self):
return iter([])
def __init__(self) -> None:
self.name = 'baseoption'
self.doc = 'baseoption'
class ElementStorage:
@ -181,13 +173,9 @@ class ElementStorage:
self.index += 1
def get(self, path):
if path not in self.paths or self.paths[path][0] is None:
raise LoaderError(_('there is no element for path {}').format(path))
return self.paths[path][0]
def get_name(self, path):
if path not in self.paths:
raise LoaderError(_('there is no element for index {}').format(path))
return f'option_{self.paths[path][1]}'
@ -207,15 +195,13 @@ class Common:
self.storage.add(self.path, self)
def populate_properties(self, child):
if child.type == 'calculation':
action = f"ParamValue('{child.name}')"
option_name = self.storage.get(child.source).get()
kwargs = f"'condition': ParamOption({option_name}, todict=True), 'expected': ParamValue('{child.expected}')"
if child.inverse:
kwargs += ", 'reverse_condition': ParamValue(True)"
prop = 'Calculation(calc_value, Params(' + action + ', kwargs={' + kwargs + '}))'
else:
prop = "'" + child.text + "'"
assert child.type == 'calculation'
action = f"ParamValue('{child.name}')"
option_name = self.storage.get(child.source).get()
kwargs = f"'condition': ParamOption({option_name}, todict=True), 'expected': ParamValue('{child.expected}')"
if child.inverse:
kwargs += ", 'reverse_condition': ParamValue(True)"
prop = 'Calculation(calc_value, Params(' + action + ', kwargs={' + kwargs + '}))'
if self.attrib['properties']:
self.attrib['properties'] += ', '
self.attrib['properties'] += prop
@ -263,15 +249,8 @@ class Common:
):
for attr in dir(space):
if not attr.startswith('_') and attr not in ERASED_ATTRIBUTES:
value = getattr(space, attr)
if isinstance(value, (list, dict)):
children = getattr(space, attr)
if children.__class__.__name__ == 'Family':
children = [children]
if isinstance(children, dict):
children = list(children.values())
if children and isinstance(children, list):
yield attr, children
if isinstance(getattr(space, attr), list):
yield attr, getattr(space, attr)
class Variable(Common):
@ -314,7 +293,7 @@ class Variable(Common):
for key in self.get_attributes(self.elt):
value = getattr(self.elt, key)
if key in FORCE_INFORMATIONS:
if key == 'test':
if key == 'test': # pragma: no cover
value = value.split(',')
if self.object_type == 'IntOption':
value = [int(v) for v in value]
@ -368,19 +347,15 @@ class Variable(Common):
def calculation_value(self, child, args):
kwargs = []
if hasattr(child, 'name'):
# has parameters
function = child.name
if hasattr(child, 'param'):
for param in child.param:
value = self.populate_param(function, param)
if not hasattr(param, 'name'):
args.append(str(value))
else:
kwargs.append(f"'{param.name}': " + value)
else:
# function without any parameter
function = child.text.strip()
# has parameters
function = child.name
if hasattr(child, 'param'):
for param in child.param:
value = self.populate_param(function, param)
if not hasattr(param, 'name'):
args.append(str(value))
else:
kwargs.append(f"'{param.name}': " + value)
ret = f"Calculation(func.{function}, Params((" + ', '.join(args) + "), kwargs=" + "{" + ', '.join(kwargs) + "})"
if hasattr(child, 'warnings_only'):
ret += f', warnings_only={child.warnings_only}'
@ -406,7 +381,7 @@ class Variable(Common):
return f'ParamInformation("{param.text}", None)'
elif param.type == 'suffix':
return f'ParamSuffix()'
raise LoaderError(_('unknown param type {}').format(param.type))
raise LoaderError(_('unknown param type {}').format(param.type)) # pragma: no cover
def populate_value(self,
child,
@ -480,11 +455,8 @@ class Family(Common):
if 'properties' in self.attrib:
self.attrib['properties'] = "'" + "', '".join(sorted(list(self.attrib['properties']))) + "'"
if hasattr(self.elt, 'property'):
#self.attrib['properties'] = ''
for child in self.elt.property:
self.populate_properties(child)
if not self.attrib['properties']:
del self.attrib['properties']
def get_object_name(self):
if 'suffixes' in self.attrib:

View File

@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="mode_conteneur_actif">
<param type="information">test_information</param>
</fill>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

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

View File

@ -8,4 +8,7 @@ try:
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])
option_3 = StrOption(properties=frozenset({'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamInformation("test_information", None)), kwargs={})))
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -1,11 +0,0 @@
from importlib.machinery import SourceFileLoader
func = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py').load_module()
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])

View File

@ -0,0 +1,34 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<services>
<service name="test">
<file name="/tmp/file" filelist="afilllist"/>
</service>
</services>
<variables>
<family name="general">
<variable name="condition" type="string" description="No change">
<value>non</value>
</variable>
<variable name="mode_conteneur_actif" type="oui/non" description="No change" hidden="True">
<value>non</value>
</variable>
<variable name="mode_conteneur_actif2" type="oui/non" description="No change" hidden="True">
<value>non</value>
</variable>
</family>
</variables>
<constraints>
<check name="valid_enum" target="condition">
<param>non</param>
<param>statique</param>
</check>
<condition name="disabled_if_not_in" source="condition">
<param>statique</param>
<target type="filelist">afilllist</target>
</condition>
</constraints>
</rougail>

View File

@ -0,0 +1 @@
{"rougail.general.condition": "non", "rougail.general.mode_conteneur_actif": "non", "rougail.general.mode_conteneur_actif2": "non", "services.test.files.file.group": "root", "services.test.files.file.mode": "0644", "services.test.files.file.name": "/tmp/file", "services.test.files.file.owner": "root", "services.test.files.file.source": "file", "services.test.files.file.templating": true}

View File

@ -8,4 +8,21 @@ try:
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])
option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='condition', doc='No change', multi=False, default='non', values=('non', 'statique'))
option_4 = ChoiceOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non'))
option_5 = ChoiceOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='mode_conteneur_actif2', doc='No change', multi=False, default='non', values=('oui', 'non'))
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3, option_4, option_5])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
option_10 = StrOption(name='group', doc='group', multi=False, default='root')
option_11 = StrOption(name='mode', doc='mode', multi=False, default='0644')
option_12 = StrOption(name='name', doc='name', multi=False, default='/tmp/file')
option_13 = StrOption(name='owner', doc='owner', multi=False, default='root')
option_14 = StrOption(name='source', doc='source', multi=False, default='file')
option_15 = BoolOption(name='templating', doc='templating', multi=False, default=True)
option_16 = BoolOption(properties=frozenset({Calculation(calc_value, Params(ParamValue('disabled'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('statique'), 'reverse_condition': ParamValue(True)}))}), name='activate', doc='activate', multi=False, default=True)
option_9 = OptionDescription(name='file', doc='file', children=[option_10, option_11, option_12, option_13, option_14, option_15, option_16])
option_8 = OptionDescription(name='files', doc='files', children=[option_9])
option_7 = OptionDescription(name='test', doc='test', children=[option_8])
option_7.impl_set_information("manage", True)
option_6 = OptionDescription(name='services', doc='services', properties=frozenset({'hidden'}), children=[option_7])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_6])

View File

@ -0,0 +1,22 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change">
<value>a</value>
</variable>
<variable name="var" type="string" description="New variable" multi="True">
<value>a</value>
<value>b</value>
<value>c</value>
</variable>
</family>
</variables>
<constraints>
<check name="valid_enum" target="mode_conteneur_actif">
<param type="variable">var</param>
</check>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1 @@
{"rougail.general.mode_conteneur_actif": "a", "rougail.general.var": ["a", "b", "c"]}

View File

@ -0,0 +1,15 @@
from importlib.machinery import SourceFileLoader
func = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py').load_module()
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_4 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='var', doc='New variable', multi=True, default=['a', 'b', 'c'], default_multi='c')
option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='a', values=Calculation(func.calc_value, Params((ParamOption(option_4)))))
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3, option_4])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<rougail>
<variables>
<family name='general'>
<variable name='varname' type='string' description="No change" multi="True">
<value>val1</value>
<value>val2</value>
</variable>
</family>
<family name='dyn' dynamic="varname">
<variable name='vardyn' type='string' description="No change">
<value>val</value>
</variable>
</family>
<family name='new'>
<variable name='newvar' type='string' description="No change"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="newvar">
<param type="variable">vardynval1</param>
</fill>
</constraints>
</rougail>

View File

@ -0,0 +1 @@
{"rougail.general.varname": ["val1", "val2"], "rougail.dynval1.vardynval1": "val", "rougail.dynval2.vardynval2": "val", "rougail.new.newvar": "val"}

View File

@ -8,4 +8,11 @@ try:
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])
option_3 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='varname', doc='No change', multi=True, default=['val1', 'val2'], default_multi='val2')
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3])
option_5 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='vardyn', doc='No change', multi=False, default='val')
option_4 = ConvertDynOptionDescription(name='dyn', doc='dyn', suffixes=Calculation(func.calc_value, Params((ParamOption(option_3)))), properties=frozenset({'normal'}), children=[option_5])
option_7 = StrOption(properties=frozenset({'normal'}), name='newvar', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamDynOption(option_5, 'val1', option_4, notraisepropertyerror=False, todict=False)), kwargs={})))
option_6 = OptionDescription(name='new', doc='new', properties=frozenset({'normal'}), children=[option_7])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2, option_4, option_6])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<rougail>
<variables>
<family name='general'>
<variable name='varname' type='string' description="No change" multi="True">
<value>val1</value>
<value>val2</value>
</variable>
</family>
<family name='dyn' dynamic="varname">
<variable name='vardyn' type='string' description="No change">
<value>val</value>
</variable>
</family>
<family name='new'>
<variable name='newvar' type='string' description="No change"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="vardyn">
<param type="suffix"/>
</fill>
</constraints>
</rougail>

View File

@ -0,0 +1 @@
{"rougail.general.varname": ["val1", "val2"], "rougail.dynval1.vardynval1": "val1", "rougail.dynval2.vardynval2": "val2", "rougail.new.newvar": null}

View File

@ -0,0 +1,18 @@
from importlib.machinery import SourceFileLoader
func = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py').load_module()
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_3 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='varname', doc='No change', multi=True, default=['val1', 'val2'], default_multi='val2')
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3])
option_5 = StrOption(properties=frozenset({'normal'}), name='vardyn', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamSuffix()), kwargs={})))
option_4 = ConvertDynOptionDescription(name='dyn', doc='dyn', suffixes=Calculation(func.calc_value, Params((ParamOption(option_3)))), properties=frozenset({'normal'}), children=[option_5])
option_7 = StrOption(properties=frozenset({'normal'}), name='newvar', doc='No change', multi=False)
option_6 = OptionDescription(name='new', doc='new', properties=frozenset({'normal'}), children=[option_7])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2, option_4, option_6])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="mode_conteneur_actif">
<param>value</param>
</fill>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

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

View File

@ -8,4 +8,7 @@ try:
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])
option_3 = StrOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamValue("value")), kwargs={})))
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

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

View File

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

View File

@ -8,4 +8,7 @@ try:
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])
option_3 = StrOption(properties=frozenset({'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamValue("value")), kwargs={})))
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -0,0 +1,33 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
</family>
<family name="general2" hidden="True">
<variable name="mode_conteneur_actif2" type="oui/non" description="No change">
<value>non</value>
</variable>
<variable name="mode_conteneur_actif3" type="string" description="No change"/>
</family>
</variables>
<constraints>
<check name="valid_enum" target="mode_conteneur_actif3">
<param>a</param>
<param>b</param>
<param>c</param>
</check>
<condition name="disabled_if_in" source="mode_conteneur_actif3">
<param>d</param>
<target type="variable">mode_conteneur_actif</target>
</condition>
<condition name="disabled_if_not_in" source="mode_conteneur_actif3">
<param>d</param>
<target type="variable">mode_conteneur_actif2</target>
</condition>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1 @@
{"rougail.general.mode_conteneur_actif": "non", "rougail.general2.mode_conteneur_actif3": "a"}

View File

@ -8,4 +8,10 @@ try:
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])
option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non'))
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3])
option_5 = ChoiceOption(properties=frozenset({'disabled', 'mandatory', 'normal'}), name='mode_conteneur_actif2', doc='No change', multi=False, default='non', values=('oui', 'non'))
option_6 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif3', doc='No change', multi=False, default='a', values=('a', 'b', 'c'))
option_4 = OptionDescription(name='general2', doc='general2', properties=frozenset({'hidden', 'normal'}), children=[option_5, option_6])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2, option_4])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -0,0 +1,17 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="Redefine description" hidden="True"/>
</family>
</variables>
<constraints>
<check name="valid_enum" target="mode_conteneur_actif">
<param>a</param>
<param>b</param>
<param>c</param>
</check>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" redefine="True" remove_check="True"/>
</family>
</variables>
<constraints>
<check name="valid_enum" target="mode_conteneur_actif">
<param>a</param>
<param>b</param>
</check>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

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

View File

@ -8,4 +8,7 @@ try:
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])
option_3 = ChoiceOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='mode_conteneur_actif', doc='Redefine description', multi=False, default='a', values=('a', 'b'))
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<rougail>
<variables>
<family name='general'>
<variable name='varname' type='string' description="No change" multi="True">
<value>val1</value>
<value>val2</value>
</variable>
</family>
<family name='dyn' dynamic="varname">
<variable name='vardyn' type='string' description="No change">
<value>val</value>
</variable>
</family>
<family name='new'>
<variable name='newvar' type='string' description="No change"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="newvar">
<param type="suffix"/>
</fill>
</constraints>
</rougail>

View File

@ -0,0 +1,33 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general" mode="expert">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
</family>
<family name="enumfam" mode="expert">
<variable name="enumvar2" type="string" description="multi">
<value>c</value>
</variable>
<variable name="enumvar" type="string" description="multi" help="bla bla bla">
<value>c</value>
</variable>
</family>
</variables>
<constraints>
<check name="valid_enum" target="enumvar">
<param>a</param>
<param>b</param>
<param>c</param>
</check>
<check name="valid_enum" target="enumvar2">
<param>a</param>
<param>b</param>
<param>c</param>
</check>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1,19 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="enumfam" mode="expert">
<variable name="enumvar" redefine="True">
<value>c</value>
</variable>
</family>
</variables>
<constraints>
<check name="valid_enum" target="enumvar">
<param>a</param>
<param>c</param>
</check>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1,23 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change">
<value>a</value>
</variable>
<variable name="var" type="string" description="New variable" multi="True">
<value>a</value>
<value>b</value>
<value>c</value>
</variable>
</family>
</variables>
<constraints>
<check name="valid_enum" target="mode_conteneur_actif">
<param type="variable">var</param>
<param>d</param>
</check>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1,28 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change">
<value>a</value>
</variable>
<variable name="var" type="string" description="New variable" multi="True">
<value>a</value>
<value>b</value>
<value>c</value>
</variable>
<variable name="var2" type="string" description="New variable" multi="True">
<value>a</value>
<value>b</value>
<value>c</value>
</variable>
</family>
</variables>
<constraints>
<check name="valid_enum" target="mode_conteneur_actif">
<param type="variable">var</param>
<param type="variable">var2</param>
</check>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1,22 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general" mode="expert">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
</family>
<family name="enumfam" mode="expert">
<variable name="enumvar" type="string" description="multi" help="bla bla bla">
<value>c</value>
</variable>
</family>
<separators/>
</variables>
<constraints>
<check name="valid_enum" target="enumvar"/>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1,20 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change">
<value>a</value>
</variable>
<variable name="var" type="string" description="New variable">
<value>a</value>
</variable>
</family>
</variables>
<constraints>
<check name="valid_enum" target="mode_conteneur_actif">
<param type="variable">var</param>
</check>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1,22 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general" mode="expert">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
</family>
<family name="enumfam" mode="expert">
<variable name="enumvar" type="number" description="enumvar" help="bla bla bla"/>
</family>
</variables>
<constraints>
<check name="valid_enum" target="enumvar">
<param type="number"/>
</check>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -5,7 +5,7 @@ from pytest import fixture, raises
from os import listdir
from json import load
from rougail import Rougail, annotator
from rougail import Rougail
from rougail.error import DictConsistencyError
from rougail.config import Config
@ -28,9 +28,10 @@ excludes = set([])
#excludes = set(['01base_file_utfchar'])
test_ok -= excludes
test_raise -= excludes
#test_ok = ['40condition_base_add']
#test_ok = ['10valid_enum_eosfunc']
#test_ok = []
#test_raise = ['80redefine_double_error']
#test_raise = []
ORI_DIR = getcwd()
@ -70,6 +71,8 @@ def launch_flattener(test_dir, test_ok=False):
Config['patch_dir'] = join(test_dir, 'patches')
eolobj.space_visitor(eosfunc)
tiramisu_objects = eolobj.save()
if 'children=[]' in tiramisu_objects.split('\n')[-2]:
raise Exception('empty tiramisu object?')
tiramisu_dir = join(test_dir, 'tiramisu')
if isdir(tiramisu_dir):
tiramisu_file = join(tiramisu_dir, 'base.py')

View File

@ -43,6 +43,7 @@ async def launch_flattener(test_dir):
for token in modulepath.split(".")[1:]:
mod = getattr(mod, token)
config = await Config(mod.option_0)
await config.information.set('test_information', 'value')
await config.property.read_only()
await config.property.pop('mandatory')
await config.information.set('info', 'value')
@ -50,7 +51,7 @@ async def launch_flattener(test_dir):
if config_dict:
if not isdir(makedict_dir):
mkdir(makedict_dir)
if debug:
if not isfile(makedict_file) or debug:
with open(makedict_file, 'w') as fh:
dump(config_dict, fh)
fh.write('\n')