refactor valid_enum
This commit is contained in:
@ -58,4 +58,4 @@ def device_type(*args, **kwargs):
|
||||
|
||||
|
||||
def calc_list(*args, **kwargs):
|
||||
return []
|
||||
return list(args)
|
||||
|
@ -20,7 +20,9 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="condition">
|
||||
<param>['tous', 'authentifié', 'aucun']</param>
|
||||
<param>tous</param>
|
||||
<param>authentifié</param>
|
||||
<param>aucun</param>
|
||||
</check>
|
||||
<condition name="hidden_if_in" source="condition">
|
||||
<param>tous</param>
|
||||
|
@ -19,7 +19,9 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="condition">
|
||||
<param>['tous', 'authentifié', 'aucun']</param>
|
||||
<param>tous</param>
|
||||
<param>authentifié</param>
|
||||
<param>aucun</param>
|
||||
</check>
|
||||
<condition name='hidden_if_in' source='condition'>
|
||||
<param>oui</param>
|
||||
|
@ -19,7 +19,10 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="enumvar">
|
||||
<param>['a', 'b', 'c', 'é']</param>
|
||||
<param>a</param>
|
||||
<param>b</param>
|
||||
<param>c</param>
|
||||
<param>é</param>
|
||||
</check>
|
||||
</constraints>
|
||||
|
||||
|
@ -19,7 +19,9 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="enumvar">
|
||||
<param>['a','b','c']</param>
|
||||
<param>a</param>
|
||||
<param>b</param>
|
||||
<param>c</param>
|
||||
</check>
|
||||
</constraints>
|
||||
|
||||
|
@ -22,10 +22,14 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="enumvar">
|
||||
<param>['a','b','c']</param>
|
||||
<param>a</param>
|
||||
<param>b</param>
|
||||
<param>c</param>
|
||||
</check>
|
||||
<check name="valid_enum" target="enumvar2">
|
||||
<param>['a','b','c']</param>
|
||||
<param>a</param>
|
||||
<param>b</param>
|
||||
<param>c</param>
|
||||
</check>
|
||||
</constraints>
|
||||
|
||||
|
@ -14,7 +14,8 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="enumvar">
|
||||
<param>['a','c']</param>
|
||||
<param>a</param>
|
||||
<param>c</param>
|
||||
</check>
|
||||
</constraints>
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<rougail>
|
||||
|
||||
<services/>
|
||||
|
||||
<variables>
|
||||
<family name="general">
|
||||
<variable name="mode_conteneur_actif" type="string" description="No change">
|
||||
<value>non</value>
|
||||
</variable>
|
||||
</family>
|
||||
<separators/>
|
||||
</variables>
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="mode_conteneur_actif">
|
||||
<param type="python">eosfunc.list_files('/notexists', default=['oui', 'non'])</param>
|
||||
</check>
|
||||
</constraints>
|
||||
|
||||
<help/>
|
||||
|
||||
</rougail>
|
||||
<!-- vim: ts=4 sw=4 expandtab
|
||||
-->
|
@ -1 +0,0 @@
|
||||
{"rougail.general.mode_conteneur_actif": "non"}
|
@ -1,8 +0,0 @@
|
||||
from tiramisu import *
|
||||
from rougail.tiramisu import ConvertDynOptionDescription
|
||||
import imp
|
||||
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
|
||||
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_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
|
||||
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])
|
@ -17,7 +17,9 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="follower1">
|
||||
<param>['a','b','c']</param>
|
||||
<param>a</param>
|
||||
<param>b</param>
|
||||
<param>c</param>
|
||||
</check>
|
||||
<group leader="leader">
|
||||
<follower>follower1</follower>
|
||||
|
@ -15,7 +15,9 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="enumvar">
|
||||
<param>['a','b','c']</param>
|
||||
<param>a</param>
|
||||
<param>b</param>
|
||||
<param>c</param>
|
||||
</check>
|
||||
</constraints>
|
||||
</rougail>
|
||||
|
@ -15,7 +15,9 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="multi">
|
||||
<param>['a','b','c']</param>
|
||||
<param>a</param>
|
||||
<param>b</param>
|
||||
<param>c</param>
|
||||
</check>
|
||||
</constraints>
|
||||
|
||||
|
@ -19,7 +19,9 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="enumvar">
|
||||
<param>['a','b','']</param>
|
||||
<param>a</param>
|
||||
<param>b</param>
|
||||
<param/>
|
||||
</check>
|
||||
</constraints>
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
</family>
|
||||
<family name="enumfam" mode="expert">
|
||||
<variable name="enumvar" type="string" description="multi">
|
||||
<value>c</value>
|
||||
<value>b</value>
|
||||
</variable>
|
||||
</family>
|
||||
<separators/>
|
||||
@ -19,7 +19,9 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="enumvar">
|
||||
<param type="python">eosfunc.calc_multi_val(['pouet'])</param>
|
||||
<param>a</param>
|
||||
<param>b</param>
|
||||
<param></param>
|
||||
</check>
|
||||
</constraints>
|
||||
|
@ -1 +1 @@
|
||||
{"rougail.general.mode_conteneur_actif": "non", "rougail.enumfam.enumvar": "test"}
|
||||
{"rougail.general.mode_conteneur_actif": "non", "rougail.enumfam.enumvar": "b"}
|
@ -4,7 +4,7 @@ import imp
|
||||
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
|
||||
option_3 = ChoiceOption(properties=frozenset({'expert', 'mandatory'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non'))
|
||||
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'expert'}), children=[option_3])
|
||||
option_5 = ChoiceOption(properties=frozenset({'expert', 'mandatory'}), name='enumvar', doc='multi', multi=False, default='test', values=('test',))
|
||||
option_5 = ChoiceOption(properties=frozenset({'expert', 'mandatory'}), name='enumvar', doc='multi', multi=False, default='b', values=('a', 'b', None))
|
||||
option_5.impl_set_information("help", "bla bla bla")
|
||||
option_4 = OptionDescription(name='enumfam', doc='enumfam', properties=frozenset({'expert'}), children=[option_5])
|
||||
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2, option_4])
|
@ -17,7 +17,9 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="enumvar">
|
||||
<param>[1, 2, 3]</param>
|
||||
<param>1</param>
|
||||
<param>2</param>
|
||||
<param>3</param>
|
||||
</check>
|
||||
</constraints>
|
||||
|
||||
|
@ -19,7 +19,9 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="enumvar">
|
||||
<param>[1, 2, 3]</param>
|
||||
<param>1</param>
|
||||
<param>2</param>
|
||||
<param>3</param>
|
||||
</check>
|
||||
</constraints>
|
||||
|
||||
|
@ -14,7 +14,9 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="mode_conteneur_actif">
|
||||
<param>['a','b','c']</param>
|
||||
<param>a</param>
|
||||
<param>b</param>
|
||||
<param>c</param>
|
||||
</check>
|
||||
</constraints>
|
||||
|
||||
|
@ -10,8 +10,11 @@
|
||||
</variable>
|
||||
</family>
|
||||
<family name="enumfam" mode="expert">
|
||||
<variable name="varmulti" type="string" description="multi" multi="True" hidden="True">
|
||||
<value>test</value>
|
||||
</variable>
|
||||
<variable name="enumvar" type="string" description="multi">
|
||||
<value>c</value>
|
||||
<value>test</value>
|
||||
</variable>
|
||||
</family>
|
||||
<separators/>
|
||||
@ -19,8 +22,11 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="enumvar">
|
||||
<param type="python">eosfunc.valid_lower('toto')</param>
|
||||
<param type="variable">varmulti</param>
|
||||
</check>
|
||||
<fill name="calc_list" target="varmulti">
|
||||
<param>test</param>
|
||||
</fill>
|
||||
</constraints>
|
||||
|
||||
<help>
|
@ -0,0 +1 @@
|
||||
{"rougail.general.mode_conteneur_actif": "non", "rougail.enumfam.enumvar": "test", "rougail.enumfam.varmulti": ["test"]}
|
12
tests/flattener_dicos/10valid_enum_variable/tiramisu/base.py
Normal file
12
tests/flattener_dicos/10valid_enum_variable/tiramisu/base.py
Normal file
@ -0,0 +1,12 @@
|
||||
from tiramisu import *
|
||||
from rougail.tiramisu import ConvertDynOptionDescription
|
||||
import imp
|
||||
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
|
||||
option_3 = ChoiceOption(properties=frozenset({'expert', 'mandatory'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non'))
|
||||
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'expert'}), children=[option_3])
|
||||
option_5 = StrOption(properties=frozenset({'expert', 'force_default_on_freeze', 'frozen', 'hidden', 'mandatory'}), name='varmulti', doc='multi', multi=True, default=Calculation(func.calc_list, Params((ParamValue("test")), kwargs={})))
|
||||
option_6 = ChoiceOption(properties=frozenset({'expert', 'mandatory'}), name='enumvar', doc='multi', multi=False, default='test', values=Calculation(func.calc_value, Params((ParamOption(option_5)))))
|
||||
option_6.impl_set_information("help", "bla bla bla")
|
||||
option_4 = OptionDescription(name='enumfam', doc='enumfam', properties=frozenset({'expert'}), 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])
|
@ -25,7 +25,8 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="condition">
|
||||
<param>['non','statique']</param>
|
||||
<param>non</param>
|
||||
<param>statique</param>
|
||||
</check>
|
||||
<condition name="disabled_if_not_in" source="condition">
|
||||
<param>statique</param>
|
@ -20,7 +20,9 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="mode_conteneur_actif3">
|
||||
<param>['a','b','c']</param>
|
||||
<param>a</param>
|
||||
<param>b</param>
|
||||
<param>c</param>
|
||||
</check>
|
||||
<condition name="disabled_if_in" source="mode_conteneur_actif3">
|
||||
<param>d</param>
|
@ -12,7 +12,9 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="mode_conteneur_actif">
|
||||
<param>['a','b','c']</param>
|
||||
<param>a</param>
|
||||
<param>b</param>
|
||||
<param>c</param>
|
||||
</check>
|
||||
</constraints>
|
||||
|
@ -12,7 +12,8 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="mode_conteneur_actif">
|
||||
<param>['a','b']</param>
|
||||
<param>a</param>
|
||||
<param>b</param>
|
||||
</check>
|
||||
</constraints>
|
||||
|
@ -1,21 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<rougail>
|
||||
<services/>
|
||||
|
||||
<variables>
|
||||
<family name="proxy authentifié">
|
||||
<variable name="toto1" type="port" description="Port d'écoute du proxy" mode="expert">
|
||||
</variable>
|
||||
<variable name="toto2" type="port" description="Port d'écoute du proxy NTLM" mode="expert">
|
||||
<value>3127</value>
|
||||
</variable>
|
||||
</family>
|
||||
</variables>
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="toto1">
|
||||
<param type="python"/>
|
||||
</check>
|
||||
</constraints>
|
||||
|
||||
</rougail>
|
@ -10,9 +10,7 @@
|
||||
</variables>
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="mode_conteneur_actif">
|
||||
<param>[]</param>
|
||||
</check>
|
||||
<check name="valid_enum" target="mode_conteneur_actif"/>
|
||||
</constraints>
|
||||
|
||||
<help/>
|
@ -10,6 +10,9 @@
|
||||
</variable>
|
||||
</family>
|
||||
<family name="enumfam" mode="expert">
|
||||
<variable name="varmulti" type="string" description="multi" hidden="True">
|
||||
<value>test</value>
|
||||
</variable>
|
||||
<variable name="enumvar" type="string" description="multi">
|
||||
<value>test</value>
|
||||
</variable>
|
||||
@ -19,8 +22,11 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="enumvar">
|
||||
<param type="python">eosfunc.calc_multi_val(['test'])</param>
|
||||
<param type="variable">varmulti</param>
|
||||
</check>
|
||||
<fill name="calc_value" target="varmulti">
|
||||
<param>test</param>
|
||||
</fill>
|
||||
</constraints>
|
||||
|
||||
<help>
|
@ -10,8 +10,11 @@
|
||||
</variable>
|
||||
</family>
|
||||
<family name="enumfam" mode="expert">
|
||||
<variable name="varmulti" type="string" description="multi" multi="True" hidden="True">
|
||||
<value>test</value>
|
||||
</variable>
|
||||
<variable name="enumvar" type="string" description="multi">
|
||||
<value>c</value>
|
||||
<value>test</value>
|
||||
</variable>
|
||||
</family>
|
||||
<separators/>
|
||||
@ -19,8 +22,11 @@
|
||||
|
||||
<constraints>
|
||||
<check name="valid_enum" target="enumvar">
|
||||
<param type="python">toto</param>
|
||||
<param type="variable">varmulti_unknown</param>
|
||||
</check>
|
||||
<fill name="calc_list" target="varmulti">
|
||||
<param>test</param>
|
||||
</fill>
|
||||
</constraints>
|
||||
|
||||
<help>
|
Reference in New Issue
Block a user