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. :param kwargs: dict of name strings to values.
""" """
#opts, paths = self.cfgimpl_get_description()._cache_paths #opts, paths = self.cfgimpl_get_description()._cache_paths
#FIXME _validate pour apply_requires ?
all_paths = [p.split(".") for p in self.getpaths(allpaths=True)] all_paths = [p.split(".") for p in self.getpaths(allpaths=True)]
for key, value in kwargs.iteritems(): for key, value in kwargs.iteritems():
key_p = key.split('.') key_p = key.split('.')

View file

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

View file

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