diff --git a/tiramisu/api.py b/tiramisu/api.py index 78857c5..f6ed3d9 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -156,9 +156,9 @@ class CommonTiramisuOption(CommonTiramisu): option = self.option_bag.option if not option.impl_is_optiondescription(): if self.option_bag.index is None and option.impl_is_master_slaves('slave'): - raise APIError('index must be set with a slave option') + raise APIError(_('index must be set with the slave option "{}"').format(self.option_bag.path)) elif self.option_bag.index is not None and not option.impl_is_master_slaves('slave'): - raise APIError('index must be set only with a slave option') + raise APIError(_('index must be set only with a slave option, not for "{}"').format(self.option_bag.path)) def __getattr__(self, name): if not hasattr(CommonTiramisuOption, name): @@ -350,6 +350,7 @@ class TiramisuOptionPermissive(CommonTiramisuOption): allow_optiondescription = True slave_need_index = False + # FIXME should have same api than property def __init__(self, name: str, subconfig: Union[KernelConfig, SubConfig], @@ -533,7 +534,7 @@ class TiramisuOption(CommonTiramisu): def _find(self, name: str, - value: Union[bool, Undefined]=undefined, + value=undefined, type=None, first: bool=False): """find an option by name (only for optiondescription)""" @@ -849,11 +850,13 @@ class TiramisuContextOption(TiramisuContext): withoption=None, fullpath=False): """return dict with path as key and value""" - return self.config_bag.context.make_dict(self.config_bag, - flatten=flatten, - fullpath=fullpath, - withoption=withoption, - withvalue=withvalue) + config_bag = self.config_bag.copy() + config_bag._setting_properties = self.config_bag.setting_properties - {'warnings'} + return config_bag.context.make_dict(config_bag, + flatten=flatten, + fullpath=fullpath, + withoption=withoption, + withvalue=withvalue) def list(self, type='all', @@ -917,8 +920,8 @@ class TiramisuContextConfig(TiramisuContext): """find a path from option name and optionnaly a value to MetaConfig or GroupConfig""" if first: return self.config_bag.context.find_firsts(byname=name, - byvalue=value, - config_bag=self.config_bag) + byvalue=value, + config_bag=self.config_bag) else: raise APIError('not implemented yet') diff --git a/tiramisu/setting.py b/tiramisu/setting.py index 88b83f7..78fbace 100644 --- a/tiramisu/setting.py +++ b/tiramisu/setting.py @@ -181,7 +181,7 @@ class ConfigBag: return 'validator' in self._setting_properties return self._validate if key == 'setting_properties': - if self.force_unrestraint: + if self.force_unrestraint or not self._validate: return None return self._setting_properties if key == '_setting_properties': @@ -195,10 +195,6 @@ class ConfigBag: def __setattr__(self, key, value): if key == 'validate': - try: - del self._setting_properties - except AttributeError: - pass self._validate = value else: super().__setattr__(key, value) @@ -208,8 +204,11 @@ class ConfigBag: for key in self.__slots__: if key == 'fromconsistency' and self.fromconsistency != []: kwargs['fromconsistency'] = copy(self.fromconsistency) + value = getattr(self, key) + if key == '_validate' and value == True: + pass else: - kwargs[key] = getattr(self, key) + kwargs[key] = value return ConfigBag(**kwargs)