support slave with list has calculated value
This commit is contained in:
parent
6ef85c4974
commit
a76815dd1f
1 changed files with 11 additions and 2 deletions
|
@ -137,6 +137,7 @@ def carry_out_calculation(option, context, callback, callback_params,
|
||||||
tcparams = {}
|
tcparams = {}
|
||||||
# if callback_params has a callback, launch several time calculate()
|
# if callback_params has a callback, launch several time calculate()
|
||||||
master_slave = False
|
master_slave = False
|
||||||
|
has_option = False
|
||||||
# multi's option should have same value for all option
|
# multi's option should have same value for all option
|
||||||
if option._is_subdyn():
|
if option._is_subdyn():
|
||||||
tcparams['suffix'] = [(option.impl_getsuffix(), False)]
|
tcparams['suffix'] = [(option.impl_getsuffix(), False)]
|
||||||
|
@ -180,6 +181,7 @@ def carry_out_calculation(option, context, callback, callback_params,
|
||||||
raise value
|
raise value
|
||||||
# convert to list, not modifie this multi
|
# convert to list, not modifie this multi
|
||||||
if value.__class__.__name__ == 'Multi':
|
if value.__class__.__name__ == 'Multi':
|
||||||
|
has_option = True
|
||||||
value = list(value)
|
value = list(value)
|
||||||
|
|
||||||
if opt.impl_is_master_slaves() and \
|
if opt.impl_is_master_slaves() and \
|
||||||
|
@ -227,6 +229,13 @@ def carry_out_calculation(option, context, callback, callback_params,
|
||||||
ret = calculate(callback, args, kwargs, returns_raise)
|
ret = calculate(callback, args, kwargs, returns_raise)
|
||||||
if not option.impl_is_optiondescription() and callback_params != {} and isinstance(ret, list) and \
|
if not option.impl_is_optiondescription() and callback_params != {} and isinstance(ret, list) and \
|
||||||
option.impl_is_master_slaves('slave'):
|
option.impl_is_master_slaves('slave'):
|
||||||
|
if not has_option and index not in [None, undefined]:
|
||||||
|
if index < len(ret):
|
||||||
|
ret = ret[index]
|
||||||
|
else:
|
||||||
|
#FIXME really?
|
||||||
|
ret = None
|
||||||
|
else:
|
||||||
raise SlaveError(_("callback cannot return a list for a "
|
raise SlaveError(_("callback cannot return a list for a "
|
||||||
"slave option ({0})").format(option.impl_getname()))
|
"slave option ({0})").format(option.impl_getname()))
|
||||||
return ret
|
return ret
|
||||||
|
|
Loading…
Reference in a new issue