Merge modification made for 1.0's branch

This commit is contained in:
2014-04-02 12:06:11 +02:00
3 changed files with 38 additions and 7 deletions

View File

@ -154,8 +154,15 @@ def carry_out_calculation(option, config, callback, callback_params,
).impl_get_path_by_opt(opt)
# get value
try:
if option.impl_is_multi() and \
(option.impl_get_multitype() == multitypes.master or
(option.impl_get_multitype() == multitypes.slave and
option.impl_get_master_slaves() != opt)):
validate = True
else:
validate = False
value = config.getattr(path, force_permissive=True,
validate=False)
validate=validate)
# convert to list, not modifie this multi
if value.__class__.__name__ == 'Multi':
value = list(value)
@ -192,7 +199,7 @@ def carry_out_calculation(option, config, callback, callback_params,
# if no index, return a list
if one_is_multi:
ret = []
if index:
if index is not None:
range_ = [index]
else:
range_ = range(len_multi)
@ -211,7 +218,7 @@ def carry_out_calculation(option, config, callback, callback_params,
else:
kwargs[key] = val
calc = calculate(callback, args, kwargs)
if index:
if index is not None:
ret = calc
else:
ret.append(calc)
@ -234,7 +241,7 @@ def carry_out_calculation(option, config, callback, callback_params,
ret = ret[:max_len]
if len(ret) < max_len:
ret = ret + [None] * (max_len - len(ret))
if isinstance(ret, list) and index:
if isinstance(ret, list) and index is not None:
if len(ret) < index + 1:
ret = None
else:

View File

@ -208,7 +208,7 @@ class Values(object):
if (opt.impl_is_multi() and
opt.impl_get_multitype() == multitypes.slave):
masterp = self._get_opt_path(opt.impl_get_master_slaves())
mastervalue = context.getattr(masterp, validate=validate)
mastervalue = context.getattr(masterp, validate=False)
lenmaster = len(mastervalue)
if lenmaster == 0:
value = []
@ -232,8 +232,6 @@ class Values(object):
if config_error is None:
if opt.impl_is_multi():
value = Multi(value, self.context, opt, path, validate)
# suppress value if already set
self.reset(opt, path)
# frozen and force default
elif is_frozen and 'force_default_on_freeze' in setting[opt]:
value = self._getdefault(opt)