diff --git a/tiramisu/config.py b/tiramisu/config.py index 3f725c9..84f1cc4 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -161,13 +161,13 @@ class Config(object): def _get_master_len(self, slave_name): try: - parent_cfg = self._cfgimpl_parent + parent_cfg = self if parent_cfg is None: return None master_name = parent_cfg._cfgimpl_descr.get_master_name() - master_value = getattr(parent_cfg, master_name) + master_value = parent_cfg._cfgimpl_values[master_name] return len(master_value) - except TypeError: + except TypeError, err: # in this case we just don't care about the len return None @@ -176,8 +176,8 @@ class Config(object): if master_len == None: return True if master_len != len(slave_value): - raise ValueError("invalid len for the group {0}" - "in the option {1} ".format(master_name, slave_name)) + raise ValueError("invalid len for the group of" + " the option {0}".format(slave_name)) def fill_multi(self, name, result, default_multi=None): """fills a multi option with default and calculated values diff --git a/tiramisu/option.py b/tiramisu/option.py index 96625b9..d49013d 100644 --- a/tiramisu/option.py +++ b/tiramisu/option.py @@ -63,14 +63,18 @@ class Multi(list): if master != self.opt._name: raise IndexError("in a group with a master, you mustn't add " "a value in a slave's Multi value") - for name, multi in self.config: - if master == multi.opt._name: - multi._setvalue(value, who=settings.owner) - else: - default_value = multi.opt.getdefault_multi() - multi._setvalue(default_value) except TypeError: - self._setvalue(value, who=settings.owner) + return self._setvalue(value, who=settings.owner) + multis = [] + for name, multi in self.config: + multis.append(multi) + for multi in multis: + if master == multi.opt._name: + ret = multi._setvalue(value, who=settings.owner) + else: + default_value = multi.opt.getdefault_multi() + multi._setvalue(default_value) + return ret def _setvalue(self, value, key=None, who=None): if value != None: @@ -96,19 +100,24 @@ class Multi(list): if master != self.opt._name: raise IndexError("in a group with a master, you mustn't remove " "a value in a slave's Multi value") - for name, multi in self.config: - if master == multi.opt._name: - multi._pop(key) - else: - change_who = False - # the value owner has to be updated because - # the default value doesn't have the same length - # of the new value - if len(multi.opt.getdefault()) >= len(multi): - change_who = True - multi._pop(key, change_who=change_who) except TypeError: - self._pop(key) + return self._pop(key) + + multis = [] + for name, multi in self.config: + multis.append(multi) + for multi in multis: + if master == multi.opt._name: + ret = multi._pop(key) + else: + change_who = False + # the value owner has to be updated because + # the default value doesn't have the same length + # of the new value + if len(multi.opt.getdefault()) >= len(multi): + change_who = True + multi._pop(key, change_who=change_who) + return ret def _pop(self, key, change_who=True): oldvalue = list(self) @@ -527,7 +536,7 @@ class OptionDescription(HiddenBaseType, DisabledBaseType): def get_master_name(self): if self.master is None: - raise TypeError('get_master_name() shall not be called in case of' + raise TypeError('get_master_name() shall not be called in case of ' 'non-master OptionDescription') return self.master # ____________________________________________________________