eosfunc and autolib
This commit is contained in:
parent
934d011847
commit
b533bd996b
4 changed files with 34 additions and 22 deletions
|
@ -19,7 +19,8 @@
|
||||||
# the whole pypy projet is under MIT licence
|
# the whole pypy projet is under MIT licence
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
"enables us to carry out a calculation and return an option's value"
|
"enables us to carry out a calculation and return an option's value"
|
||||||
from tiramisu.error import PropertiesOptionError, ConflictConfigError
|
from tiramisu.error import PropertiesOptionError, ConflictConfigError,
|
||||||
|
NoValueReturned
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
# automatic Option object
|
# automatic Option object
|
||||||
#def special_owner_factory(name, owner, value,
|
#def special_owner_factory(name, owner, value,
|
||||||
|
@ -67,22 +68,34 @@ def carry_out_calculation(name, callback, callback_params, config):
|
||||||
for key, couple in tcparams.items():
|
for key, couple in tcparams.items():
|
||||||
value, ismulti = couple
|
value, ismulti = couple
|
||||||
if ismulti and value != None:
|
if ismulti and value != None:
|
||||||
|
if key == '':
|
||||||
|
params.append(value[incr])
|
||||||
|
else:
|
||||||
tcp[key] = value[incr]
|
tcp[key] = value[incr]
|
||||||
|
else:
|
||||||
|
if key == '':
|
||||||
|
params.append(value)
|
||||||
else:
|
else:
|
||||||
tcp[key] = value
|
tcp[key] = value
|
||||||
ret.append(calculate(name, callback, tcp))
|
ret.append(calculate(name, callback, tcp))
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
tcp = {}
|
tcp = {}
|
||||||
|
params = []
|
||||||
for key, couple in tcparams.items():
|
for key, couple in tcparams.items():
|
||||||
|
if key == '':
|
||||||
|
params.append(couple[0])
|
||||||
|
else:
|
||||||
tcp[key] = couple[0]
|
tcp[key] = couple[0]
|
||||||
return calculate(name, callback, tcp)
|
return calculate(name, callback, params, tcp)
|
||||||
|
|
||||||
def calculate(name, callback, tcparams):
|
def calculate(name, callback, params, tcparams):
|
||||||
try:
|
try:
|
||||||
# XXX not only creole...
|
# XXX not only creole...
|
||||||
from creole import eosfunc
|
from creole import eosfunc
|
||||||
return getattr(eosfunc, callback)(**tcparams)
|
return getattr(eosfunc, callback)(*params, **tcparams)
|
||||||
|
except NoValueReturned, err:
|
||||||
|
return ""
|
||||||
except AttributeError, err:
|
except AttributeError, err:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
|
@ -231,9 +231,6 @@ class Config(object):
|
||||||
(self.__class__, name))
|
(self.__class__, name))
|
||||||
if not isinstance(opt_or_descr, OptionDescription):
|
if not isinstance(opt_or_descr, OptionDescription):
|
||||||
# options with callbacks (fill or auto)
|
# options with callbacks (fill or auto)
|
||||||
if name == 'interface_gw':
|
|
||||||
print "pouet"
|
|
||||||
print opt_or_descr.has_callback()
|
|
||||||
if opt_or_descr.has_callback():
|
if opt_or_descr.has_callback():
|
||||||
value = self._cfgimpl_values[name]
|
value = self._cfgimpl_values[name]
|
||||||
if (not opt_or_descr.is_frozen() or \
|
if (not opt_or_descr.is_frozen() or \
|
||||||
|
|
|
@ -21,4 +21,5 @@ class RequirementRecursionError(RequiresError):
|
||||||
pass
|
pass
|
||||||
class MandatoryError(Exception):
|
class MandatoryError(Exception):
|
||||||
pass
|
pass
|
||||||
|
class NoValueReturned(Exception):
|
||||||
|
pass
|
||||||
|
|
|
@ -23,9 +23,10 @@
|
||||||
from tiramisu.basetype import HiddenBaseType, DisabledBaseType
|
from tiramisu.basetype import HiddenBaseType, DisabledBaseType
|
||||||
from tiramisu.error import (ConfigError, ConflictConfigError, NotFoundError,
|
from tiramisu.error import (ConfigError, ConflictConfigError, NotFoundError,
|
||||||
RequiresError, RequirementRecursionError, MandatoryError)
|
RequiresError, RequirementRecursionError, MandatoryError)
|
||||||
available_actions = ['hide', 'show', 'enable', 'disable']
|
available_actions = ['hide', 'show', 'enable', 'disable', 'freeze', 'unfreeze']
|
||||||
reverse_actions = {'hide': 'show', 'show': 'hide',
|
reverse_actions = {'hide': 'show', 'show': 'hide',
|
||||||
'disable':'enable', 'enable': 'disable'}
|
'disable': 'enable', 'enable': 'disable',
|
||||||
|
'freeze': 'unfreeze', 'unfreeze': 'freeze'}
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
# OptionDescription authorized group_type values
|
# OptionDescription authorized group_type values
|
||||||
group_types = ['default', 'family', 'group', 'master']
|
group_types = ['default', 'family', 'group', 'master']
|
||||||
|
|
Loading…
Reference in a new issue