do not validate 'warnings' in make_dict
This commit is contained in:
parent
f6e963ae38
commit
7a4a22f52d
|
@ -156,9 +156,9 @@ class CommonTiramisuOption(CommonTiramisu):
|
||||||
option = self.option_bag.option
|
option = self.option_bag.option
|
||||||
if not option.impl_is_optiondescription():
|
if not option.impl_is_optiondescription():
|
||||||
if self.option_bag.index is None and option.impl_is_master_slaves('slave'):
|
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'):
|
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):
|
def __getattr__(self, name):
|
||||||
if not hasattr(CommonTiramisuOption, name):
|
if not hasattr(CommonTiramisuOption, name):
|
||||||
|
@ -350,6 +350,7 @@ class TiramisuOptionPermissive(CommonTiramisuOption):
|
||||||
allow_optiondescription = True
|
allow_optiondescription = True
|
||||||
slave_need_index = False
|
slave_need_index = False
|
||||||
|
|
||||||
|
# FIXME should have same api than property
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
name: str,
|
name: str,
|
||||||
subconfig: Union[KernelConfig, SubConfig],
|
subconfig: Union[KernelConfig, SubConfig],
|
||||||
|
@ -533,7 +534,7 @@ class TiramisuOption(CommonTiramisu):
|
||||||
|
|
||||||
def _find(self,
|
def _find(self,
|
||||||
name: str,
|
name: str,
|
||||||
value: Union[bool, Undefined]=undefined,
|
value=undefined,
|
||||||
type=None,
|
type=None,
|
||||||
first: bool=False):
|
first: bool=False):
|
||||||
"""find an option by name (only for optiondescription)"""
|
"""find an option by name (only for optiondescription)"""
|
||||||
|
@ -849,11 +850,13 @@ class TiramisuContextOption(TiramisuContext):
|
||||||
withoption=None,
|
withoption=None,
|
||||||
fullpath=False):
|
fullpath=False):
|
||||||
"""return dict with path as key and value"""
|
"""return dict with path as key and value"""
|
||||||
return self.config_bag.context.make_dict(self.config_bag,
|
config_bag = self.config_bag.copy()
|
||||||
flatten=flatten,
|
config_bag._setting_properties = self.config_bag.setting_properties - {'warnings'}
|
||||||
fullpath=fullpath,
|
return config_bag.context.make_dict(config_bag,
|
||||||
withoption=withoption,
|
flatten=flatten,
|
||||||
withvalue=withvalue)
|
fullpath=fullpath,
|
||||||
|
withoption=withoption,
|
||||||
|
withvalue=withvalue)
|
||||||
|
|
||||||
def list(self,
|
def list(self,
|
||||||
type='all',
|
type='all',
|
||||||
|
@ -917,8 +920,8 @@ class TiramisuContextConfig(TiramisuContext):
|
||||||
"""find a path from option name and optionnaly a value to MetaConfig or GroupConfig"""
|
"""find a path from option name and optionnaly a value to MetaConfig or GroupConfig"""
|
||||||
if first:
|
if first:
|
||||||
return self.config_bag.context.find_firsts(byname=name,
|
return self.config_bag.context.find_firsts(byname=name,
|
||||||
byvalue=value,
|
byvalue=value,
|
||||||
config_bag=self.config_bag)
|
config_bag=self.config_bag)
|
||||||
else:
|
else:
|
||||||
raise APIError('not implemented yet')
|
raise APIError('not implemented yet')
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ class ConfigBag:
|
||||||
return 'validator' in self._setting_properties
|
return 'validator' in self._setting_properties
|
||||||
return self._validate
|
return self._validate
|
||||||
if key == 'setting_properties':
|
if key == 'setting_properties':
|
||||||
if self.force_unrestraint:
|
if self.force_unrestraint or not self._validate:
|
||||||
return None
|
return None
|
||||||
return self._setting_properties
|
return self._setting_properties
|
||||||
if key == '_setting_properties':
|
if key == '_setting_properties':
|
||||||
|
@ -195,10 +195,6 @@ class ConfigBag:
|
||||||
|
|
||||||
def __setattr__(self, key, value):
|
def __setattr__(self, key, value):
|
||||||
if key == 'validate':
|
if key == 'validate':
|
||||||
try:
|
|
||||||
del self._setting_properties
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
self._validate = value
|
self._validate = value
|
||||||
else:
|
else:
|
||||||
super().__setattr__(key, value)
|
super().__setattr__(key, value)
|
||||||
|
@ -208,8 +204,11 @@ class ConfigBag:
|
||||||
for key in self.__slots__:
|
for key in self.__slots__:
|
||||||
if key == 'fromconsistency' and self.fromconsistency != []:
|
if key == 'fromconsistency' and self.fromconsistency != []:
|
||||||
kwargs['fromconsistency'] = copy(self.fromconsistency)
|
kwargs['fromconsistency'] = copy(self.fromconsistency)
|
||||||
|
value = getattr(self, key)
|
||||||
|
if key == '_validate' and value == True:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
kwargs[key] = getattr(self, key)
|
kwargs[key] = value
|
||||||
return ConfigBag(**kwargs)
|
return ConfigBag(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue