support slave with list has calculated value

This commit is contained in:
Emmanuel Garette 2016-04-08 16:21:50 +02:00
parent 6ef85c4974
commit a76815dd1f
1 changed files with 11 additions and 2 deletions

View File

@ -137,6 +137,7 @@ def carry_out_calculation(option, context, callback, callback_params,
tcparams = {}
# if callback_params has a callback, launch several time calculate()
master_slave = False
has_option = False
# multi's option should have same value for all option
if option._is_subdyn():
tcparams['suffix'] = [(option.impl_getsuffix(), False)]
@ -180,6 +181,7 @@ def carry_out_calculation(option, context, callback, callback_params,
raise value
# convert to list, not modifie this multi
if value.__class__.__name__ == 'Multi':
has_option = True
value = list(value)
if opt.impl_is_master_slaves() and \
@ -227,8 +229,15 @@ def carry_out_calculation(option, context, callback, callback_params,
ret = calculate(callback, args, kwargs, returns_raise)
if not option.impl_is_optiondescription() and callback_params != {} and isinstance(ret, list) and \
option.impl_is_master_slaves('slave'):
raise SlaveError(_("callback cannot return a list for a "
"slave option ({0})").format(option.impl_getname()))
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 "
"slave option ({0})").format(option.impl_getname()))
return ret