Some optimisations
This commit is contained in:
@ -553,10 +553,6 @@ class Option(OnlyOption):
|
||||
try:
|
||||
# valid with self._validator
|
||||
calculation_validator(_value)
|
||||
# if not context launch consistency validation
|
||||
if context is not undefined:
|
||||
descr._valid_consistency(current_opt, _value, context,
|
||||
_index, submulti_index)
|
||||
self._second_level_validation(_value, self._is_warnings_only())
|
||||
except ValueError as error:
|
||||
log.debug(_('do_validation for {0}: error in value').format(
|
||||
@ -786,17 +782,16 @@ class Option(OnlyOption):
|
||||
return DynSymLinkOption(name, self, dyn=path)
|
||||
|
||||
def _validate_callback(self, callback, callback_params):
|
||||
if callback is None:
|
||||
return
|
||||
try:
|
||||
default_multi = self.impl_getdefault_multi()
|
||||
except AttributeError:
|
||||
default_multi = None
|
||||
if callback is not None and ((not self.impl_is_multi() and
|
||||
(self.impl_getdefault() is not None or
|
||||
default_multi is not None))
|
||||
or (self.impl_is_multi() and
|
||||
(self.impl_getdefault() != [] or
|
||||
default_multi is not None))
|
||||
): # pragma: optional cover
|
||||
if (not self.impl_is_multi() and (self.impl_getdefault() is not None or
|
||||
default_multi is not None)) or \
|
||||
(self.impl_is_multi() and (self.impl_getdefault() != [] or
|
||||
default_multi is not None)): # pragma: optional cover
|
||||
raise ValueError(_("default value not allowed if option: {0} "
|
||||
"is calculated").format(self.impl_getname()))
|
||||
|
||||
|
@ -115,25 +115,25 @@ class MasterSlaves(object):
|
||||
|
||||
def getitem(self, values, opt, path, validate, force_permissive,
|
||||
force_properties, validate_properties, slave_path=undefined,
|
||||
slave_value=undefined, setting_properties=undefined):
|
||||
slave_value=undefined, setting_properties=undefined, settings=undefined):
|
||||
if self.is_master(opt):
|
||||
return self._getmaster(values, opt, path, validate,
|
||||
force_permissive, force_properties,
|
||||
validate_properties, slave_path,
|
||||
slave_value, setting_properties)
|
||||
slave_value, settings)
|
||||
else:
|
||||
return self._getslave(values, opt, path, validate,
|
||||
force_permissive, force_properties,
|
||||
validate_properties, setting_properties)
|
||||
validate_properties, setting_properties, settings)
|
||||
|
||||
def _getmaster(self, values, opt, path, validate, force_permissive,
|
||||
force_properties, validate_properties, c_slave_path,
|
||||
c_slave_value, setting_properties):
|
||||
c_slave_value, settings):
|
||||
value = values._get_validated_value(opt, path, validate,
|
||||
force_permissive,
|
||||
force_properties,
|
||||
validate_properties,
|
||||
setting_properties=setting_properties)
|
||||
settings=settings)
|
||||
if validate is True:
|
||||
masterlen = len(value)
|
||||
for slave in self.getslaves(opt):
|
||||
@ -148,7 +148,7 @@ class MasterSlaves(object):
|
||||
False,
|
||||
None, False,
|
||||
None,
|
||||
setting_properties=setting_properties)
|
||||
settings=settings)
|
||||
slavelen = len(slave_value)
|
||||
self.validate_slave_length(masterlen, slavelen, slave.impl_getname(), opt)
|
||||
except ConfigError: # pragma: optional cover
|
||||
@ -156,7 +156,8 @@ class MasterSlaves(object):
|
||||
return value
|
||||
|
||||
def _getslave(self, values, opt, path, validate, force_permissive,
|
||||
force_properties, validate_properties, setting_properties):
|
||||
force_properties, validate_properties, setting_properties,
|
||||
settings):
|
||||
"""
|
||||
if master has length 0:
|
||||
return []
|
||||
@ -191,7 +192,7 @@ class MasterSlaves(object):
|
||||
False,
|
||||
None, # not undefined
|
||||
with_meta=master_is_meta,
|
||||
setting_properties=setting_properties)
|
||||
settings=settings)
|
||||
#if slave, had values until master's one
|
||||
path = opt.impl_getpath(context)
|
||||
valuelen = len(value)
|
||||
@ -206,7 +207,7 @@ class MasterSlaves(object):
|
||||
validate_properties=False,
|
||||
with_meta=master_is_meta,
|
||||
index=index,
|
||||
setting_properties=setting_properties),
|
||||
settings=settings),
|
||||
setitem=False,
|
||||
force=True,
|
||||
validate=validate)
|
||||
|
@ -93,7 +93,6 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
return _impl_getpaths(self, include_groups, _currpath)
|
||||
|
||||
def impl_build_cache_consistency(self, _consistencies=None, cache_option=None):
|
||||
#FIXME cache_option !
|
||||
if _consistencies is None:
|
||||
init = True
|
||||
_consistencies = {}
|
||||
@ -114,7 +113,6 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
if init and _consistencies != {}:
|
||||
self._cache_consistencies = {}
|
||||
for opt, cons in _consistencies.items():
|
||||
#FIXME dans le cache ...
|
||||
if opt._get_id() not in cache_option: # pragma: optional cover
|
||||
raise ConfigError(_('consistency with option {0} '
|
||||
'which is not in Config').format(
|
||||
|
Reference in New Issue
Block a user