notraisepropertyerror => propertyerror

This commit is contained in:
Emmanuel Garette 2021-02-07 09:23:01 +01:00
parent f03fcfa11a
commit 0100c692b2
15 changed files with 65 additions and 19 deletions

View file

@ -111,6 +111,7 @@
<!ELEMENT value (#PCDATA)>
<!ELEMENT constraints ((fill* | check* | condition* | group*)*)>
<!ELEMENT fill (param*)>
<!ATTLIST fill name CDATA #REQUIRED>
<!ATTLIST fill target CDATA #REQUIRED>
@ -127,19 +128,19 @@
<!ATTLIST condition force_condition_on_fallback (True|False) "False">
<!ATTLIST condition force_inverse_condition_on_fallback (True|False) "False">
<!ELEMENT group (follower+)>
<!ATTLIST group leader CDATA #REQUIRED>
<!ATTLIST group name CDATA #IMPLIED>
<!ATTLIST group description CDATA #IMPLIED>
<!ELEMENT param (#PCDATA)>
<!ATTLIST param type (string|number|variable|information|suffix) "string">
<!ATTLIST param name CDATA #IMPLIED>
<!ATTLIST param notraisepropertyerror (True|False) "False">
<!ATTLIST param propertyerror (True|False) "True">
<!ATTLIST param optional (True|False) "False">
<!ELEMENT target (#PCDATA)>
<!ATTLIST target type (family|variable|filelist|iplist|portlist) "variable">
<!ATTLIST target optional (True|False) "False">
<!ELEMENT group (follower+)>
<!ATTLIST group leader CDATA #REQUIRED>
<!ATTLIST group name CDATA #IMPLIED>
<!ATTLIST group description CDATA #IMPLIED>
<!ELEMENT follower (#PCDATA)>

View file

@ -334,8 +334,8 @@ class Variable(Common):
params.extend([f"'{param.suffix}'", f'{param.family.reflector_name}'])
else:
param_type = 'ParamOption'
if param.notraisepropertyerror:
params.append(f'notraisepropertyerror={param.notraisepropertyerror}')
if not param.propertyerror:
params.append('notraisepropertyerror=True')
return "{}({})".format(param_type, ', '.join(params))

View file

@ -0,0 +1,24 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="condition" type="string">
<value>no</value>
</variable>
<variable name="variable1" type="string"/>
<variable name="variable2" type="string"/>
</family>
</variables>
<constraints>
<condition name="disabled_if_in" source="condition">
<param>no</param>
<target type="variable">variable1</target>
</condition>
<fill name="calc_val" target="variable2">
<param type="variable" propertyerror="False">variable1</param>
</fill>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View file

@ -0,0 +1 @@
{"rougail.general.condition": "no", "rougail.general.variable2": null}

View file

@ -0,0 +1,20 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
spec = spec_from_loader(loader.name, loader)
func = module_from_spec(spec)
loader.exec_module(func)
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(name="condition", doc="condition", default="no", properties=frozenset({"mandatory", "normal"}))
option_4 = StrOption(name="variable1", doc="variable1", properties=frozenset({"normal", Calculation(func.calc_value, Params(ParamValue('disabled'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('no')}))}))
option_5 = StrOption(name="variable2", doc="variable2", default=Calculation(func.calc_val, Params((ParamOption(option_4, notraisepropertyerror=True)))), properties=frozenset({"normal"}))
option_2 = OptionDescription(name="general", doc="general", children=[option_3, option_4, option_5], properties=frozenset({"normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])

View file

@ -15,7 +15,7 @@
<constraints>
<fill name='calc_multi_condition' target='extra.ejabberd.day'>
<param>non</param>
<param type='variable' name='condition_1' notraisepropertyerror='True'>activer_ejabberd</param>
<param type='variable' name='condition_1' propertyerror='False'>activer_ejabberd</param>
<param name='match'>none</param>
<param name='mismatch'>daily</param>
</fill>

View file

@ -15,7 +15,7 @@
<constraints>
<fill name='calc_multi_condition' target='extra.ejabberd.day'>
<param>non</param>
<param type='variable' name='condition_1' notraisepropertyerror='True'>activer_ejabberd</param>
<param type='variable' name='condition_1' propertyerror='False'>activer_ejabberd</param>
<param name='match'>none</param>
<param name='mismatch'>daily</param>
</fill>

View file

@ -14,7 +14,7 @@
<constraints>
<fill name='calc_multi_condition' target='extra.ejabberd.day'>
<param>non</param>
<param type='variable' name='condition_1' notraisepropertyerror='True'>activer_ejabberd</param>
<param type='variable' name='condition_1' propertyerror='False'>activer_ejabberd</param>
<param name='match'>none</param>
<param name='mismatch'>daily</param>
</fill>

View file

@ -15,7 +15,7 @@
<constraints>
<fill name='calc_multi_condition' target='extra.ejabberd.day'>
<param>non</param>
<param type='variable' name='condition_1' notraisepropertyerror='True'>activer_ejabberd</param>
<param type='variable' name='condition_1' propertyerror='False'>activer_ejabberd</param>
<param name='match'>none</param>
<param name='mismatch'>daily</param>
</fill>

View file

@ -15,7 +15,7 @@
<constraints>
<fill name='calc_multi_condition' target='extra.ejabberd.day'>
<param>non</param>
<param type='variable' name='condition_1' notraisepropertyerror='True'>activer_ejabberd</param>
<param type='variable' name='condition_1' propertyerror='False'>activer_ejabberd</param>
<param name='match'>none</param>
<param name='mismatch'>daily</param>
</fill>

View file

@ -15,9 +15,9 @@
<constraints>
<fill name="calc_multi_condition" target="toto1">
<param>non</param>
<param type="variable" name="condition_1" notraisepropertyerror="False"/>
<param type="variable" name="condition_1" propertyerror="True"/>
<param name="match">3128</param>
<param name="mismatch" type="variable" notraisepropertyerror="False">toto2</param>
<param name="mismatch" type="variable" propertyerror="True">toto2</param>
</fill>
</constraints>

View file

@ -15,9 +15,9 @@
<constraints>
<fill name="calc_multi_condition" target="toto1">
<param>non</param>
<param type="number" name="condition_2" notraisepropertyerror="False"/>
<param type="number" name="condition_2" propertyerror="True"/>
<param name="match">3128</param>
<param name="mismatch" type="variable" notraisepropertyerror="False">toto2</param>
<param name="mismatch" type="variable" propertyerror="True">toto2</param>
</fill>
</constraints>

View file

@ -15,7 +15,7 @@
<constraints>
<fill name='calc_multi_condition' target='extra.ejabberd.day'>
<param>non</param>
<param type='variable' name='condition_1' notraisepropertyerror='True'>activer_ejabberd</param>
<param type='variable' name='condition_1' propertyerror='True'>activer_ejabberd</param>
<param name='match'>none</param>
<param name='mismatch'>daily</param>
</fill>

View file

@ -15,7 +15,7 @@
<constraints>
<fill name='calc_multi_condition' target='extra.ejabberd.day'>
<param>non</param>
<param type='variable' name='condition_1' notraisepropertyerror='True'>activer_ejabberd</param>
<param type='variable' name='condition_1' propertyerror='False'>activer_ejabberd</param>
<param name='match'>none</param>
<param name='mismatch'>daily</param>
</fill>