add OptionInformation support

This commit is contained in:
Emmanuel Garette 2020-10-03 22:10:32 +02:00
parent b55b8f4d9d
commit 5b3d57812e
27 changed files with 56 additions and 20 deletions

View File

@ -422,6 +422,8 @@ class Variable(Common):
if hasattr(param, 'suffix'):
value['suffix'] = param.suffix
return self.build_param(value)
elif param.type == 'information':
return f'ParamInformation("{param.text}")'
raise LoaderError(_('unknown param type {}').format(param.type))
def populate_value(self,

View File

@ -1,7 +1,8 @@
from tiramisu import valid_not_equal, valid_ip_netmask, calc_value
def calc_val(*args, **kwargs):
pass
if len(args) > 0:
return args[0]
def concat(*args, **kwargs):

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": null, "rougail.general.mode_conteneur_actif1": "non"}
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.mode_conteneur_actif1": "non"}

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": null, "rougail.general.mode_conteneur_actif1": "non", "rougail.general.module_instancie": "non"}
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.mode_conteneur_actif1": "non", "rougail.general.module_instancie": "non"}

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": null, "rougail.general.mode_conteneur_actif1": "non"}
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.mode_conteneur_actif1": "non"}

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": null, "rougail.general.mode_conteneur_actif1": "non"}
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.mode_conteneur_actif1": "non"}

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": null, "rougail.general.mode_conteneur_actif1": "non"}
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.mode_conteneur_actif1": "non"}

View File

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

View File

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

View File

@ -0,0 +1,8 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_3 = StrOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamInformation("info")), 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

@ -5,7 +5,7 @@
<variables>
<family name="general" mode="basic">
<variable name="mode_conteneur_actif" type="domain" description="No change" mandatory="True" mode="expert"/>
<variable name="mode_conteneur_actif" type="oui/non" description="No change" mandatory="True" mode="expert"/>
<variable name="mode_conteneur_actif1" type="oui/non" description="No change">
<value>non</value>
</variable>

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": null, "rougail.general.mode_conteneur_actif1": "non"}
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.mode_conteneur_actif1": "non"}

View File

@ -3,7 +3,7 @@ from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_4 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif1', doc='No change', multi=False, default='non', values=('oui', 'non'))
option_3 = DomainnameOption(type='domainname', allow_ip=False, properties=frozenset({'expert', 'mandatory'}), name='mode_conteneur_actif', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamOption(option_4, notraisepropertyerror=False, todict=False)), kwargs={})))
option_3 = ChoiceOption(properties=frozenset({'expert', 'mandatory'}), name='mode_conteneur_actif', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamOption(option_4, notraisepropertyerror=False, todict=False)), kwargs={})), values=('oui', 'non'))
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

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": null, "rougail.general.mode_conteneur_actif1": "non"}
{"rougail.general.mode_conteneur_actif": 3, "rougail.general.mode_conteneur_actif1": "non"}

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": null, "rougail.general.mode_conteneur_actif1": "non"}
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.mode_conteneur_actif1": "non"}

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.autosavevar": null}
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.autosavevar": "oui"}

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.autosavevar": null}
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.autosavevar": "oui"}

View File

@ -1 +1 @@
{"rougail.general.condition": "non", "rougail.general.mode_conteneur_actif": null, "rougail.general.mode_conteneur_actif2": "non"}
{"rougail.general.condition": "non", "rougail.general.mode_conteneur_actif": "non", "rougail.general.mode_conteneur_actif2": "non"}

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "non", "rougail.enumfam.enumvar": "test", "rougail.enumfam.varmulti": ["test"]}
{"rougail.general.mode_conteneur_actif": "non", "rougail.enumfam.varmulti": ["test"], "rougail.enumfam.enumvar": "test"}

View File

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

View File

@ -1 +1 @@
{"rougail.general.varname": [1, 2], "rougail.dyn1.vardyn1": "val", "rougail.dyn2.vardyn2": "val", "rougail.new.newvar": null}
{"rougail.general.varname": [1, 2], "rougail.dyn1.vardyn1": "val", "rougail.dyn2.vardyn2": "val", "rougail.new.newvar": "val"}

View File

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

View File

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

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "non", "extra.test.delay": 0, "extra.test.calc_url": null}
{"rougail.general.mode_conteneur_actif": "non", "extra.test.delay": 0, "extra.test.calc_url": "http://localhost/"}

View File

@ -48,6 +48,7 @@ async def launch_flattener(test_dir):
config = await Config(mod.option_0)
await config.property.read_only()
await config.property.pop('mandatory')
await config.information.set('info', 'value')
config_dict = await config.value.dict()
if config_dict:
if not isdir(makedict_dir):