don't launch apply_requires more than needed

This commit is contained in:
Emmanuel Garette 2013-04-08 16:12:23 +02:00
parent 67e67a5020
commit 0c5ab9df18
3 changed files with 8 additions and 7 deletions

View File

@ -393,6 +393,7 @@ class Config(SubConfig):
:param kwargs: dict of name strings to values.
"""
#opts, paths = self.cfgimpl_get_description()._cache_paths
#FIXME _validate pour apply_requires ?
all_paths = [p.split(".") for p in self.getpaths(allpaths=True)]
for key, value in kwargs.iteritems():
key_p = key.split('.')

View File

@ -25,7 +25,7 @@ from copy import copy
from types import FunctionType
from tiramisu.error import (ConfigError, NotFoundError, ConflictConfigError,
RequiresError)
from tiramisu.setting import groups, multitypes, apply_requires
from tiramisu.setting import groups, multitypes
name_regexp = re.compile(r'^\d+')
@ -237,10 +237,10 @@ class Option(BaseInformation):
"config has been frozen".format(name))
if setting.has_property('frozen') and setting.has_property('frozen',
self):
self, False):
raise TypeError('cannot change the value to %s for '
'option %s this option is frozen' % (str(value), name))
apply_requires(self, config)
#apply_requires(self, config)
config.cfgimpl_get_values()[self] = value
def getkey(self, value):

View File

@ -83,7 +83,7 @@ class Values(object):
else:
set_mandatory = ('mandatory' in force_properties or
setting.has_property('mandatory'))
if setting.has_property('mandatory', opt) and set_mandatory:
if setting.has_property('mandatory', opt, False) and set_mandatory:
if self._is_empty(opt, value) and opt.is_empty_by_default():
raise MandatoryError("option: {0} is mandatory "
"and shall have a value".format(opt._name))
@ -122,14 +122,14 @@ class Values(object):
# options with callbacks
value = self._get_value(opt)
setting = self.context.cfgimpl_get_settings()
is_frozen = setting.has_property('frozen', opt)
is_frozen = setting.has_property('frozen', opt, False)
if opt.has_callback():
#if value is set and :
# - not frozen
# - frozen and not force_default_on_freeze
if not self.is_default_owner(opt) and (
not is_frozen or (is_frozen and
not setting.has_property('force_default_on_freeze', opt))):
not setting.has_property('force_default_on_freeze', opt, False))):
return value
value = self._getcallback_value(opt)
if opt.is_multi():
@ -140,7 +140,7 @@ class Values(object):
#suppress value if already set
self.reset(opt)
# frozen and force default
elif is_frozen and setting.has_property('force_default_on_freeze', opt):
elif is_frozen and setting.has_property('force_default_on_freeze', opt, False):
value = opt.getdefault()
if opt.is_multi():
value = self.fill_multi(opt, value)