From a76815dd1f3ad479390b1eb803b629442ef42964 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Fri, 8 Apr 2016 16:21:50 +0200 Subject: [PATCH] support slave with list has calculated value --- tiramisu/autolib.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tiramisu/autolib.py b/tiramisu/autolib.py index ffcdee8..6985a97 100644 --- a/tiramisu/autolib.py +++ b/tiramisu/autolib.py @@ -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