refactore _launch_consistency

This commit is contained in:
Emmanuel Garette 2016-10-12 21:55:01 +02:00
parent 1b87e1d9bb
commit 0eff0cd989
1 changed files with 12 additions and 13 deletions

View File

@ -395,10 +395,12 @@ class Option(OnlyOption):
all_cons_vals = [] all_cons_vals = []
val_consistencies = True val_consistencies = True
for opt in all_cons_opts: for opt in all_cons_opts:
#get value
if (isinstance(opt, DynSymLinkOption) and option._dyn == opt._dyn) or \ if (isinstance(opt, DynSymLinkOption) and option._dyn == opt._dyn) or \
option == opt: option == opt:
opt_value = value # option is current option
# we have already value, so use it
all_cons_vals.append(value)
else: else:
#if context, calculate value, otherwise get default value #if context, calculate value, otherwise get default value
if context is not undefined: if context is not undefined:
@ -407,6 +409,7 @@ class Option(OnlyOption):
else: else:
path = descr.impl_get_path_by_opt(opt) path = descr.impl_get_path_by_opt(opt)
opt_value = context.getattr(path, validate=False, opt_value = context.getattr(path, validate=False,
index=index,
force_permissive=True, force_permissive=True,
returns_raise=True) returns_raise=True)
if isinstance(opt_value, Exception): if isinstance(opt_value, Exception):
@ -419,20 +422,16 @@ class Option(OnlyOption):
return return
else: else:
return opt_value return opt_value
else: elif index is None:
opt_value = opt.impl_getdefault() opt_value = opt.impl_getdefault()
#append value
if not self.impl_is_multi() or (isinstance(opt, DynSymLinkOption)
and option._dyn == opt._dyn) or \
option == opt:
all_cons_vals.append(opt_value)
else:
if index is not None:
all_cons_vals.append(opt_value[index])
else: else:
#only check properties for slaves opt_value = opt.impl_getdefault()[index]
if self.impl_is_multi() and index is None:
# only check propertyerror for master/slaves is transitive
val_consistencies = False val_consistencies = False
all_cons_vals.append(opt_value)
if val_consistencies: if val_consistencies:
return getattr(self, func)(current_opt, all_cons_opts, all_cons_vals, warnings_only) return getattr(self, func)(current_opt, all_cons_opts, all_cons_vals, warnings_only)