can add personal function
This commit is contained in:
parent
43e30bba47
commit
4b21b1507f
|
@ -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
|
||||||
|
|
|
@ -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])
|
|
@ -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>
|
Loading…
Reference in New Issue