suppression of the override
This commit is contained in:
parent
1de236d2a8
commit
09dba4b959
|
@ -45,7 +45,8 @@ def test_reset_value():
|
|||
def test_base_config_and_groups():
|
||||
descr = make_description()
|
||||
# overrides the booloption default value
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
assert config.gc.name == 'ref'
|
||||
assert config.bool == False
|
||||
nm = config.unwrap_from_path('gc.name')
|
||||
|
@ -58,8 +59,8 @@ def test_base_config_and_groups():
|
|||
def test_base_config_in_a_tree():
|
||||
"how options are organized into a tree"
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
assert config.gc.name == 'ref'
|
||||
config.gc.name = 'framework'
|
||||
assert config.gc.name == 'framework'
|
||||
|
@ -84,20 +85,23 @@ def test_base_config_in_a_tree():
|
|||
|
||||
raises(AttributeError, 'config.gc.foo = "bar"')
|
||||
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
assert config.gc.name == 'ref'
|
||||
config.wantframework = True
|
||||
|
||||
def test_config_values():
|
||||
"_cfgimpl_values appears to be a simple dict"
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
config.set(dummy=False)
|
||||
assert config.gc._cfgimpl_values == {'dummy': False, 'float': 2.3, 'name': 'ref'}
|
||||
|
||||
def test_cfgimpl_get_home_by_path():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
assert config._cfgimpl_get_home_by_path('gc.dummy')[1] == 'dummy'
|
||||
assert config._cfgimpl_get_home_by_path('dummy')[1] == 'dummy'
|
||||
assert config.getpaths(include_groups=False) == ['gc.name', 'gc.dummy', 'gc.float', 'bool', 'objspace', 'wantref', 'str', 'wantframework', 'int', 'boolop']
|
||||
|
|
|
@ -30,7 +30,8 @@ def test_compare_configs():
|
|||
"config object comparison"
|
||||
descr = make_description()
|
||||
conf1 = Config(descr)
|
||||
conf2 = Config(descr, wantref=True)
|
||||
conf2 = Config(descr)
|
||||
conf2.wantref = True
|
||||
assert conf1 != conf2
|
||||
assert hash(conf1) != hash(conf2)
|
||||
assert conf1.getkey() != conf2.getkey()
|
||||
|
|
|
@ -130,12 +130,14 @@ def test_newoption_add_in_subdescr():
|
|||
descr = make_description()
|
||||
newoption = BoolOption('newoption', 'dummy twoo', default=False)
|
||||
descr.gc.add_child(newoption)
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
assert config.gc.newoption == False
|
||||
|
||||
def test_newoption_add_in_config():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
newoption = BoolOption('newoption', 'dummy twoo', default=False)
|
||||
descr.add_child(newoption)
|
||||
config.cfgimpl_update()
|
||||
|
@ -211,4 +213,3 @@ def test_disabled_with_group():
|
|||
cfg.int = 1
|
||||
raises(PropertiesOptionError, "cfg.gc.name")
|
||||
assert gcgroup._is_disabled()
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ def test_mandatory():
|
|||
config.dummy1 = True
|
||||
assert config.dummy1 == True
|
||||
raises(MandatoryError, 'config.dummy2 == None')
|
||||
raises(MandatoryError, "config.override({'dummy2':None})")
|
||||
# raises(MandatoryError, "config.override({'dummy2':None})")
|
||||
config.set(dummy2=True)
|
||||
config.dummy2 = False
|
||||
assert config.dummy2 == False
|
||||
|
@ -81,13 +81,13 @@ def test_force_default_on_freeze():
|
|||
|
||||
def test_override_are_defaults():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
config.gc.dummy = True
|
||||
assert config._cfgimpl_values['gc']._cfgimpl_value_owners['dummy'] == 'user'
|
||||
#Options have an available default setting and can give it back
|
||||
assert config._cfgimpl_descr._children[0]._children[1].getdefault() == False
|
||||
config.override({'gc.dummy':True})
|
||||
# config.override({'gc.dummy':True})
|
||||
#assert config.gc.dummy == True
|
||||
#assert config._cfgimpl_descr._children[0]._children[1].getdefault() == True
|
||||
#assert config._cfgimpl_values['gc']._cfgimpl_value_owners['dummy'] == 'default'
|
||||
|
@ -98,8 +98,8 @@ def test_overrides_changes_option_value():
|
|||
BoolOption("b", "", default=False)])
|
||||
config = Config(descr)
|
||||
config.b = True
|
||||
config.override({'b': False})
|
||||
assert config.b == False
|
||||
# config.override({'b': False})
|
||||
# assert config.b == False
|
||||
#____________________________________________________________
|
||||
# test various option types
|
||||
def test_choice_with_no_default():
|
||||
|
@ -132,4 +132,3 @@ def test_arbitrary_option():
|
|||
c1.a.append(1)
|
||||
assert c2.a == []
|
||||
assert c1.a == [1]
|
||||
|
||||
|
|
|
@ -48,28 +48,30 @@ def make_description2():
|
|||
intoption, boolop])
|
||||
return descr
|
||||
|
||||
def test_override_are_default_owner():
|
||||
"config.override() implies that the owner is 'default' again"
|
||||
descr = make_description2()
|
||||
config = Config(descr, bool=False)
|
||||
# default
|
||||
assert config.gc._cfgimpl_value_owners['dummy'] == 'default'
|
||||
# user
|
||||
config.gc.dummy = True
|
||||
assert config.gc._cfgimpl_value_owners['dummy'] == 'user'
|
||||
assert config._cfgimpl_values['gc']._cfgimpl_value_owners['dummy'] == 'user'
|
||||
#Options have an available default setting and can give it back
|
||||
assert config._cfgimpl_descr._children[0]._children[1].getdefault() == False
|
||||
config.override({'gc.dummy':True})
|
||||
assert config.gc._cfgimpl_value_owners['dummy'] == 'default'
|
||||
# user again
|
||||
config.gc.dummy = False
|
||||
assert config.gc._cfgimpl_value_owners['dummy'] == 'user'
|
||||
#def test_override_are_default_owner():
|
||||
# "config.override() implies that the owner is 'default' again"
|
||||
# descr = make_description2()
|
||||
# config = Config(descr)
|
||||
# config.bool = False
|
||||
# # default
|
||||
# assert config.gc._cfgimpl_value_owners['dummy'] == 'default'
|
||||
# # user
|
||||
# config.gc.dummy = True
|
||||
# assert config.gc._cfgimpl_value_owners['dummy'] == 'user'
|
||||
# assert config._cfgimpl_values['gc']._cfgimpl_value_owners['dummy'] == 'user'
|
||||
# #Options have an available default setting and can give it back
|
||||
# assert config._cfgimpl_descr._children[0]._children[1].getdefault() == False
|
||||
# config.override({'gc.dummy':True})
|
||||
# assert config.gc._cfgimpl_value_owners['dummy'] == 'default'
|
||||
# # user again
|
||||
# config.gc.dummy = False
|
||||
# assert config.gc._cfgimpl_value_owners['dummy'] == 'user'
|
||||
|
||||
def test_has_callback():
|
||||
descr = make_description()
|
||||
# here the owner is 'default'
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
# because dummy has a callback
|
||||
dummy = config.unwrap_from_path('gc.dummy')
|
||||
config.cfgimpl_freeze()
|
||||
|
@ -79,7 +81,8 @@ def test_has_callback():
|
|||
#____________________________________________________________
|
||||
def test_freeze_and_has_callback_with_setoption():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
config.cfgimpl_freeze()
|
||||
dummy = config.unwrap_from_path('gc.dummy')
|
||||
dummy.freeze()
|
||||
|
|
|
@ -52,7 +52,7 @@ def test_reset():
|
|||
config.string = "foo"
|
||||
assert config.string == "foo"
|
||||
assert config._cfgimpl_value_owners['string'] == 'user'
|
||||
config.string = None
|
||||
config.unwrap_from_path("string").reset(config)
|
||||
assert config.string == 'string'
|
||||
assert config._cfgimpl_value_owners['string'] == 'default'
|
||||
|
||||
|
@ -60,13 +60,15 @@ def test_reset_with_multi():
|
|||
s = StrOption("string", "", default=["string"], default_multi="string" , multi=True)
|
||||
descr = OptionDescription("options", "", [s])
|
||||
config = Config(descr)
|
||||
config.string = []
|
||||
# config.string = []
|
||||
config.unwrap_from_path("string").reset(config)
|
||||
assert config.string == ["string"]
|
||||
assert config._cfgimpl_value_owners['string'] == ['default']
|
||||
config.string = ["eggs", "spam", "foo"]
|
||||
assert config._cfgimpl_value_owners['string'] == ['user', 'user', 'user']
|
||||
config.string = []
|
||||
assert config.string == ["string"]
|
||||
config.unwrap_from_path("string").reset(config)
|
||||
# assert config.string == ["string"]
|
||||
assert config._cfgimpl_value_owners['string'] == ['default']
|
||||
raises(ConfigError, "config.string = None")
|
||||
|
||||
|
@ -324,7 +326,8 @@ def test_set_symlink_option():
|
|||
#____________________________________________________________
|
||||
def test_config_impl_values():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
# gcdummy.setoption(config, True, "user")
|
||||
# config.setoption("gc.dummy", True, "user")
|
||||
#config.gc.dummy = True
|
||||
|
@ -346,13 +349,13 @@ def test_accepts_multiple_changes_from_option():
|
|||
assert s.getdefault() == "string"
|
||||
assert config.string == "egg"
|
||||
s.setoption(config, 'blah', "default")
|
||||
assert s.getdefault() == "blah"
|
||||
assert s.getdefault() == "string"
|
||||
assert config.string == "blah"
|
||||
s.setoption(config, 'bol', "user")
|
||||
assert config.string == 'bol'
|
||||
config.override({'string': "blurp"})
|
||||
assert config.string == 'blurp'
|
||||
assert s.getdefault() == 'blurp'
|
||||
# config.override({'string': "blurp"})
|
||||
# assert config.string == 'blurp'
|
||||
# assert s.getdefault() == 'blurp'
|
||||
|
||||
def test_allow_multiple_changes_from_config():
|
||||
"""
|
||||
|
@ -371,17 +374,18 @@ def test_allow_multiple_changes_from_config():
|
|||
assert config.bip.string2 == 'blah'
|
||||
# ____________________________________________________________
|
||||
|
||||
def test_overrides_are_defaults():
|
||||
descr = OptionDescription("test", "", [
|
||||
BoolOption("b1", "", default=False),
|
||||
BoolOption("b2", "", default=False),
|
||||
])
|
||||
# overrides here
|
||||
config = Config(descr, b2=True)
|
||||
assert config.b2
|
||||
# test with a require
|
||||
config.b1 = True
|
||||
assert config.b2
|
||||
#def test_overrides_are_defaults():
|
||||
# descr = OptionDescription("test", "", [
|
||||
# BoolOption("b1", "", default=False),
|
||||
# BoolOption("b2", "", default=False),
|
||||
# ])
|
||||
# # overrides here
|
||||
# config = Config(descr)
|
||||
# config.b2 = True
|
||||
# assert config.b2
|
||||
# # test with a require
|
||||
# config.b1 = True
|
||||
# assert config.b2
|
||||
|
||||
# ____________________________________________________________
|
||||
# accessing a value by the get method
|
||||
|
@ -407,4 +411,3 @@ def test_access_by_get_whith_hide():
|
|||
])
|
||||
c = Config(descr)
|
||||
raises(PropertiesOptionError, "c.get('b1')")
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@ def make_description():
|
|||
intoption, boolop])
|
||||
return descr
|
||||
|
||||
def test_base_config_and_groups():
|
||||
descr = make_description()
|
||||
# overrides the booloption default value
|
||||
config = Config(descr, bool=False)
|
||||
assert config.gc.hide == True
|
||||
#def test_base_config_and_groups():
|
||||
# descr = make_description()
|
||||
# # overrides the booloption default value
|
||||
# config = Config(descr, bool=False)
|
||||
# assert config.gc.hide == True
|
||||
|
||||
def test_root_config_answers_ok():
|
||||
"if you hide the root config, the options in this namespace behave normally"
|
||||
|
@ -42,6 +42,3 @@ def test_root_config_answers_ok():
|
|||
cfg.cfgimpl_enable_property('hiddend') #cfgimpl_hide()
|
||||
assert cfg.dummy == False
|
||||
assert cfg.boolop == True
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -25,11 +25,12 @@ from tiramisu.error import (PropertiesOptionError, ConfigError, NotFoundError,
|
|||
AmbigousOptionError, ConflictConfigError, NoMatchingOptionFound,
|
||||
MandatoryError, MethodCallError, NoValueReturned)
|
||||
from tiramisu.option import (OptionDescription, Option, SymLinkOption,
|
||||
group_types, Multi, apply_requires)
|
||||
group_types, Multi, apply_requires, Owner)
|
||||
|
||||
# ______________________________________________________________________
|
||||
# generic owner. 'default' is the general config owner after init time
|
||||
default_owner = 'user'
|
||||
|
||||
# ____________________________________________________________
|
||||
class Config(object):
|
||||
"properties attribute: the name of a property enables this property"
|
||||
|
@ -41,12 +42,10 @@ class Config(object):
|
|||
_cfgimpl_owner = default_owner
|
||||
_cfgimpl_toplevel = None
|
||||
|
||||
def __init__(self, descr, parent=None, **overrides):
|
||||
def __init__(self, descr, parent=None):
|
||||
""" Configuration option management master class
|
||||
:param descr: describes the configuration schema
|
||||
:type descr: an instance of ``option.OptionDescription``
|
||||
:param overrides: can be used to set different default values
|
||||
(see method ``override``)
|
||||
:param parent: is None if the ``Config`` is root parent Config otherwise
|
||||
:type parent: ``Config``
|
||||
"""
|
||||
|
@ -61,7 +60,7 @@ class Config(object):
|
|||
self._cfgimpl_toplevel = self._cfgimpl_get_toplevel()
|
||||
'`freeze()` allows us to carry out this calculation again if necessary'
|
||||
self._cfgimpl_frozen = self._cfgimpl_toplevel._cfgimpl_frozen
|
||||
self._cfgimpl_build(overrides)
|
||||
self._cfgimpl_build()
|
||||
|
||||
def _validate_duplicates(self, children):
|
||||
"""duplicates Option names in the schema
|
||||
|
@ -75,11 +74,10 @@ class Config(object):
|
|||
raise ConflictConfigError('duplicate option name: '
|
||||
'{0}'.format(dup._name))
|
||||
|
||||
def _cfgimpl_build(self, overrides):
|
||||
def _cfgimpl_build(self):
|
||||
"""
|
||||
- builds the config object from the schema
|
||||
- settles various default values for options
|
||||
:param overrides: dict of options name:default values
|
||||
"""
|
||||
self._validate_duplicates(self._cfgimpl_descr._children)
|
||||
for child in self._cfgimpl_descr._children:
|
||||
|
@ -99,7 +97,7 @@ class Config(object):
|
|||
elif isinstance(child, OptionDescription):
|
||||
self._validate_duplicates(child._children)
|
||||
self._cfgimpl_values[child._name] = Config(child, parent=self)
|
||||
self.override(overrides)
|
||||
# self.override(overrides)
|
||||
|
||||
def cfgimpl_set_permissive(self, permissive):
|
||||
if not isinstance(permissive, list):
|
||||
|
@ -126,14 +124,14 @@ class Config(object):
|
|||
if child._name not in self._cfgimpl_values:
|
||||
self._cfgimpl_values[child._name] = Config(child, parent=self)
|
||||
|
||||
def override(self, overrides):
|
||||
"""
|
||||
overrides default values. This marks the overridden values as defaults.
|
||||
:param overrides: is a dictionary of path strings to values.
|
||||
"""
|
||||
for name, value in overrides.iteritems():
|
||||
homeconfig, name = self._cfgimpl_get_home_by_path(name)
|
||||
homeconfig.setoption(name, value, 'default')
|
||||
# def override(self, overrides):
|
||||
# """
|
||||
# overrides default values. This marks the overridden values as defaults.
|
||||
# :param overrides: is a dictionary of path strings to values.
|
||||
# """
|
||||
# for name, value in overrides.iteritems():
|
||||
# homeconfig, name = self._cfgimpl_get_home_by_path(name)
|
||||
# homeconfig.setoption(name, value, 'default')
|
||||
|
||||
def cfgimpl_set_owner(self, owner):
|
||||
":param owner: sets the default value for owner at the Config level"
|
||||
|
@ -369,35 +367,22 @@ class Config(object):
|
|||
:type who: string
|
||||
"""
|
||||
child = getattr(self._cfgimpl_descr, name)
|
||||
if who == None:
|
||||
if child.is_multi():
|
||||
newowner = [self._cfgimpl_owner for i in range(len(value))]
|
||||
else:
|
||||
newowner = self._cfgimpl_owner
|
||||
else:
|
||||
if type(child) != SymLinkOption:
|
||||
if child.is_multi():
|
||||
if type(value) != Multi:
|
||||
if type(value) == list:
|
||||
value = Multi(value, self, child)
|
||||
else:
|
||||
raise ConfigError("invalid value for option:"
|
||||
" {0} that is set to multi".format(name))
|
||||
newowner = [who for i in range(len(value))]
|
||||
else:
|
||||
newowner = who
|
||||
if type(child) != SymLinkOption:
|
||||
#if child.has_callback() and who=='default':
|
||||
# raise TypeError("trying to set a default value to an option "
|
||||
# "which has a callback: {0}".format(name))
|
||||
if who == None:
|
||||
who = self._cfgimpl_owner
|
||||
if child.is_multi():
|
||||
if type(value) != Multi:
|
||||
if type(value) == list:
|
||||
value = Multi(value, self, child)
|
||||
else:
|
||||
raise ConfigError("invalid value for option:"
|
||||
" {0} that is set to multi".format(name))
|
||||
newowner = [who for i in range(len(value))]
|
||||
else:
|
||||
newowner = who
|
||||
child.setoption(self, value, who)
|
||||
if (value is None and who != 'default' and not child.is_multi()):
|
||||
child.setowner(self, 'default')
|
||||
self._cfgimpl_values[name] = copy(child.getdefault())
|
||||
elif (value == [] and who != 'default' and child.is_multi()):
|
||||
child.setowner(self, ['default' for i in range(len(child.getdefault()))])
|
||||
self._cfgimpl_values[name] = Multi(copy(child.getdefault()),
|
||||
config=self, child=child)
|
||||
if child.is_multi() and value == [] and who != 'default':
|
||||
child.setowner(self, Owner(who))
|
||||
else:
|
||||
child.setowner(self, newowner)
|
||||
else:
|
||||
|
@ -757,4 +742,3 @@ def mandatory_warnings(config):
|
|||
except PropertiesOptionError:
|
||||
pass
|
||||
config._cfgimpl_get_toplevel()._cfgimpl_mandatory = mandatory
|
||||
|
||||
|
|
|
@ -43,8 +43,19 @@ master~slave group, the name of the group and the name of the
|
|||
master option are identical.
|
||||
"""
|
||||
group_types = ['default', 'family', 'group', 'master']
|
||||
|
||||
# ____________________________________________________________
|
||||
# multi types
|
||||
|
||||
class Owner(str):
|
||||
"an owner just for a multi Option that have no value set"
|
||||
# we need a string that cannot be iterable
|
||||
def __iter__(self):
|
||||
raise StopIteration
|
||||
|
||||
def __len__(self):
|
||||
return 0
|
||||
|
||||
class Multi(list):
|
||||
"container that support items for the values of list (multi) options"
|
||||
def __init__(self, lst, config, child):
|
||||
|
@ -58,23 +69,16 @@ class Multi(list):
|
|||
def append(self, value):
|
||||
self.setoption(value)
|
||||
|
||||
def setoption(self, value, key=None):
|
||||
#owners = self.child.getowner(self.config)
|
||||
# None is replaced by default_multi
|
||||
if value == None:
|
||||
defval = self.child.getdefault()
|
||||
if key is not None and len(defval) > key:
|
||||
value = defval[key]
|
||||
else:
|
||||
value = self.child.default_multi
|
||||
who = 'default'
|
||||
else:
|
||||
def setoption(self, value, key=None, who=None):
|
||||
if who is None:
|
||||
who = self.config._cfgimpl_owner
|
||||
if not self.child._validate(value):
|
||||
raise ConfigError("invalid value {0} "
|
||||
"for option {1}".format(str(value), self.child._name))
|
||||
if not self.child._validate(value):
|
||||
raise ConfigError("invalid value {0} "
|
||||
"for option {1}".format(str(value), self.child._name))
|
||||
oldvalue = list(self)
|
||||
oldowner = self.child.getowner(self.config)
|
||||
if isinstance(oldowner, Owner):
|
||||
oldowner = []
|
||||
if key is None:
|
||||
ret = super(Multi, self).append(value)
|
||||
oldvalue.append(None)
|
||||
|
@ -105,6 +109,11 @@ class Option(HiddenBaseType, DisabledBaseType):
|
|||
def __init__(self, name, doc, default=None, default_multi=None,
|
||||
requires=None, mandatory=False, multi=False, callback=None,
|
||||
callback_params=None):
|
||||
"""
|
||||
:param default: ['bla', 'bla', 'bla']
|
||||
:param default_multi: 'bla' (used in case of a reset to default only at
|
||||
a given index)
|
||||
"""
|
||||
self._name = name
|
||||
self.doc = doc
|
||||
self._requires = requires
|
||||
|
@ -211,7 +220,7 @@ class Option(HiddenBaseType, DisabledBaseType):
|
|||
"""
|
||||
name = self._name
|
||||
if self.is_multi():
|
||||
if not type(owner) == list:
|
||||
if not type(owner) == list and not isinstance(owner, Owner):
|
||||
raise ConfigError("invalid owner for multi "
|
||||
"option: {0}".format(name))
|
||||
config._cfgimpl_value_owners[name] = owner
|
||||
|
@ -220,6 +229,27 @@ class Option(HiddenBaseType, DisabledBaseType):
|
|||
"config *must* be only the **parent** config (not the toplevel config)"
|
||||
return config._cfgimpl_value_owners[self._name]
|
||||
|
||||
def reset(self, config, idx=None):
|
||||
"""resets the default value and owner
|
||||
:param idx: if not None, resets only the element at index idx
|
||||
"""
|
||||
if self.is_multi():
|
||||
if idx is not None:
|
||||
defval = self.getdefault()
|
||||
# if the default is ['a', 'b', 'c']
|
||||
if len(defval) > idx:
|
||||
# and idx = 4 -> there is actually no such value in the default
|
||||
value.setoption(default_multi, idx, who='default')
|
||||
else:
|
||||
# and idx = 2 -> there is a value in the default
|
||||
value.setoption(defval[idx], idx, who='default')
|
||||
else:
|
||||
value = Multi(self.getdefault(), config, self)
|
||||
config.setoption(self._name, value, 'default')
|
||||
else:
|
||||
value = self.getdefault()
|
||||
config.setoption(self._name, value, 'default')
|
||||
|
||||
def is_default_owner(self, config, all_default=True, at_index=None):
|
||||
"""
|
||||
:param config: *must* be only the **parent** config
|
||||
|
@ -274,29 +304,7 @@ class Option(HiddenBaseType, DisabledBaseType):
|
|||
if config.is_frozen() and self.is_frozen():
|
||||
raise TypeError('cannot change the value to %s for '
|
||||
'option %s' % (str(value), name))
|
||||
if who == "default":
|
||||
# changes the default value (and therefore resets the previous value)
|
||||
if self._validate(value):
|
||||
self.default = value
|
||||
else:
|
||||
raise ConfigError("invalid value %s for option %s" % (value, name))
|
||||
apply_requires(self, config)
|
||||
# FIXME put the validation for the multi somewhere else
|
||||
# # it is a multi **and** it has requires
|
||||
# if self.multi == True:
|
||||
# if type(value) != list:
|
||||
# raise TypeError("value {0} must be a list".format(value))
|
||||
# if self._requires is not None:
|
||||
# for reqname in self._requires:
|
||||
# # FIXME : verify that the slaves are all multi
|
||||
# #option = getattr(config._cfgimpl_descr, reqname)
|
||||
# # if not option.multi == True:
|
||||
# # raise ConflictConfigError("an option with requires "
|
||||
# # "has to be a list type : {0}".format(name))
|
||||
# if len(config._cfgimpl_values[reqname]) != len(value):
|
||||
# raise ConflictConfigError("an option with requires "
|
||||
# "has not the same length of the others "
|
||||
# "in the group : {0}".format(reqname))
|
||||
if type(config._cfgimpl_values[name]) == Multi:
|
||||
config._cfgimpl_previous_values[name] = list(config._cfgimpl_values[name])
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue