Compare commits
2 Commits
3040a11de9
...
4b21b1507f
Author | SHA1 | Date |
---|---|---|
Emmanuel Garette | 4b21b1507f | |
Emmanuel Garette | 43e30bba47 |
|
@ -596,7 +596,9 @@ class ConstraintAnnotator:
|
||||||
if not hasattr(objectspace.space, 'constraints'):
|
if not hasattr(objectspace.space, 'constraints'):
|
||||||
return
|
return
|
||||||
self.objectspace = objectspace
|
self.objectspace = objectspace
|
||||||
self.eosfunc = imp.load_source('eosfunc', eosfunc_file)
|
eosfunc = imp.load_source('eosfunc', eosfunc_file)
|
||||||
|
self.functions = dir(eosfunc)
|
||||||
|
self.functions.extend(INTERNAL_FUNCTIONS)
|
||||||
self.valid_enums = {}
|
self.valid_enums = {}
|
||||||
if hasattr(self.objectspace.space.constraints, 'check'):
|
if hasattr(self.objectspace.space.constraints, 'check'):
|
||||||
self.check_check()
|
self.check_check()
|
||||||
|
@ -618,10 +620,8 @@ class ConstraintAnnotator:
|
||||||
|
|
||||||
def check_check(self):
|
def check_check(self):
|
||||||
remove_indexes = []
|
remove_indexes = []
|
||||||
functions = dir(self.eosfunc)
|
|
||||||
functions.extend(INTERNAL_FUNCTIONS)
|
|
||||||
for check_idx, check in enumerate(self.objectspace.space.constraints.check):
|
for check_idx, check in enumerate(self.objectspace.space.constraints.check):
|
||||||
if not check.name in functions:
|
if not check.name in self.functions:
|
||||||
raise DictConsistencyError(_('cannot find check function {}').format(check.name))
|
raise DictConsistencyError(_('cannot find check function {}').format(check.name))
|
||||||
if hasattr(check, 'param'):
|
if hasattr(check, 'param'):
|
||||||
param_option_indexes = []
|
param_option_indexes = []
|
||||||
|
@ -1008,7 +1008,6 @@ class ConstraintAnnotator:
|
||||||
indexes = list(fills.keys())
|
indexes = list(fills.keys())
|
||||||
indexes.sort()
|
indexes.sort()
|
||||||
targets = []
|
targets = []
|
||||||
eosfunc = dir(self.eosfunc)
|
|
||||||
for idx in indexes:
|
for idx in indexes:
|
||||||
fill = fills[idx]
|
fill = fills[idx]
|
||||||
# test if it's redefined calculation
|
# test if it's redefined calculation
|
||||||
|
@ -1016,7 +1015,7 @@ class ConstraintAnnotator:
|
||||||
raise DictConsistencyError(_(f"A fill already exists for the target: {fill.target}"))
|
raise DictConsistencyError(_(f"A fill already exists for the target: {fill.target}"))
|
||||||
targets.append(fill.target)
|
targets.append(fill.target)
|
||||||
#
|
#
|
||||||
if fill.name not in eosfunc:
|
if fill.name not in self.functions:
|
||||||
raise DictConsistencyError(_('cannot find fill function {}').format(fill.name))
|
raise DictConsistencyError(_('cannot find fill function {}').format(fill.name))
|
||||||
|
|
||||||
namespace = fill.namespace
|
namespace = fill.namespace
|
||||||
|
@ -1037,6 +1036,9 @@ class ConstraintAnnotator:
|
||||||
raise DictConsistencyError(_(f"All '{param.type}' variables must have a value in order to calculate {fill.target}"))
|
raise DictConsistencyError(_(f"All '{param.type}' variables must have a value in order to calculate {fill.target}"))
|
||||||
if param.type == 'suffix' and hasattr(param, 'text'):
|
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}"))
|
raise DictConsistencyError(_(f"All '{param.type}' variables must not have a value in order to calculate {fill.target}"))
|
||||||
|
if param.type == 'string':
|
||||||
|
if not hasattr(param, 'text'):
|
||||||
|
param.text = None
|
||||||
if param.type == 'variable':
|
if param.type == 'variable':
|
||||||
try:
|
try:
|
||||||
param.text, suffix = self.objectspace.paths.get_variable_path(param.text,
|
param.text, suffix = self.objectspace.paths.get_variable_path(param.text,
|
||||||
|
|
|
@ -44,13 +44,16 @@ class TiramisuReflector:
|
||||||
funcs_path,
|
funcs_path,
|
||||||
):
|
):
|
||||||
self.storage = ElementStorage()
|
self.storage = ElementStorage()
|
||||||
self.storage.text = ["try:",
|
self.storage.text = ["import imp",
|
||||||
|
f"func = imp.load_source('func', '{funcs_path}')",
|
||||||
|
"for key, value in dict(locals()).items():",
|
||||||
|
" if key != ['imp', 'func']:",
|
||||||
|
" setattr(func, key, value)",
|
||||||
|
"try:",
|
||||||
" from tiramisu3 import *",
|
" from tiramisu3 import *",
|
||||||
"except:",
|
"except:",
|
||||||
" from tiramisu import *",
|
" from tiramisu import *",
|
||||||
"from rougail.tiramisu import ConvertDynOptionDescription",
|
"from rougail.tiramisu import ConvertDynOptionDescription",
|
||||||
"import imp",
|
|
||||||
f"func = imp.load_source('func', '{funcs_path}')",
|
|
||||||
]
|
]
|
||||||
self.make_tiramisu_objects(xmlroot)
|
self.make_tiramisu_objects(xmlroot)
|
||||||
# parse object
|
# parse object
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?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>
|
||||||
|
<fill name="calc_multi_condition" target="toto1">
|
||||||
|
<param/>
|
||||||
|
</fill>
|
||||||
|
</constraints>
|
||||||
|
|
||||||
|
</rougail>
|
|
@ -0,0 +1,2 @@
|
||||||
|
{"rougail.proxy_authentifie.toto1": null, "rougail.proxy_authentifie.toto2": "3127"}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
try:
|
||||||
|
from tiramisu3 import *
|
||||||
|
except:
|
||||||
|
from tiramisu import *
|
||||||
|
from rougail.tiramisu import ConvertDynOptionDescription
|
||||||
|
import imp
|
||||||
|
func = imp.load_source('func', 'tests/dictionaries/../eosfunc/test.py')
|
||||||
|
option_3 = PortOption(allow_private=True, properties=frozenset({'expert'}), name='toto1', doc='Port d\'écoute du proxy', multi=False, default=Calculation(func.calc_multi_condition, Params((ParamValue("None")), kwargs={})))
|
||||||
|
option_4 = PortOption(allow_private=True, properties=frozenset({'expert', 'mandatory'}), name='toto2', doc='Port d\'écoute du proxy NTLM', multi=False, default='3127')
|
||||||
|
option_2 = OptionDescription(name='proxy_authentifie', doc='proxy authentifié', properties=frozenset({'expert'}), 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])
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?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>
|
||||||
|
<fill name="calc_multi_condition" target="toto1">
|
||||||
|
<param name="value"/>
|
||||||
|
</fill>
|
||||||
|
</constraints>
|
||||||
|
|
||||||
|
</rougail>
|
|
@ -0,0 +1,2 @@
|
||||||
|
{"rougail.proxy_authentifie.toto1": null, "rougail.proxy_authentifie.toto2": "3127"}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
try:
|
||||||
|
from tiramisu3 import *
|
||||||
|
except:
|
||||||
|
from tiramisu import *
|
||||||
|
from rougail.tiramisu import ConvertDynOptionDescription
|
||||||
|
import imp
|
||||||
|
func = imp.load_source('func', 'tests/dictionaries/../eosfunc/test.py')
|
||||||
|
option_3 = PortOption(allow_private=True, properties=frozenset({'expert'}), name='toto1', doc='Port d\'écoute du proxy', multi=False, default=Calculation(func.calc_multi_condition, Params((), kwargs={'value': ParamValue("None")})))
|
||||||
|
option_4 = PortOption(allow_private=True, properties=frozenset({'expert', 'mandatory'}), name='toto2', doc='Port d\'écoute du proxy NTLM', multi=False, default='3127')
|
||||||
|
option_2 = OptionDescription(name='proxy_authentifie', doc='proxy authentifié', properties=frozenset({'expert'}), 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])
|
|
@ -12,7 +12,9 @@
|
||||||
|
|
||||||
<constraints>
|
<constraints>
|
||||||
<check name="valid_enum" target="mode_conteneur_actif">
|
<check name="valid_enum" target="mode_conteneur_actif">
|
||||||
<param>['a','b','c']</param>
|
<param>a</param>
|
||||||
|
<param>b</param>
|
||||||
|
<param>c</param>
|
||||||
</check>
|
</check>
|
||||||
</constraints>
|
</constraints>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?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>
|
||||||
|
<fill name="calc_multi_condition" target="toto1">
|
||||||
|
<param name="value" type="number"/>
|
||||||
|
</fill>
|
||||||
|
</constraints>
|
||||||
|
|
||||||
|
</rougail>
|
|
@ -17,7 +17,9 @@
|
||||||
|
|
||||||
<constraints>
|
<constraints>
|
||||||
<check name="valid_enum" target="enumvar">
|
<check name="valid_enum" target="enumvar">
|
||||||
<param>['a', 'b', 'c']</param>
|
<param>a</param>
|
||||||
|
<param>b</param>
|
||||||
|
<param>c</param>
|
||||||
</check>
|
</check>
|
||||||
</constraints>
|
</constraints>
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,9 @@
|
||||||
|
|
||||||
<constraints>
|
<constraints>
|
||||||
<check name="valid_enum" target="enumvar">
|
<check name="valid_enum" target="enumvar">
|
||||||
<param>[1, 2, 3]</param>
|
<param>1</param>
|
||||||
|
<param>2</param>
|
||||||
|
<param>3</param>
|
||||||
</check>
|
</check>
|
||||||
</constraints>
|
</constraints>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue