add OptionInformation support

This commit is contained in:
Emmanuel Garette 2020-10-03 22:10:32 +02:00
parent 246ac25791
commit 5eba872969
21 changed files with 23 additions and 19 deletions

View file

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

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

@ -5,7 +5,7 @@
<variables> <variables>
<family name="general" mode="basic"> <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"> <variable name="mode_conteneur_actif1" type="oui/non" description="No change">
<value>non</value> <value>non</value>
</variable> </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

@ -6,7 +6,7 @@ from rougail.tiramisu import ConvertDynOptionDescription
import imp import imp
func = imp.load_source('func', 'tests/dictionaries/../eosfunc/test.py') func = imp.load_source('func', 'tests/dictionaries/../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_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_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_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) 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.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

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

View file

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