mandatory options
This commit is contained in:
parent
5907f3e663
commit
e2ec79063e
@ -185,22 +185,26 @@ class Option(HiddenBaseType, DisabledBaseType):
|
||||
"who is **not necessarily** a owner because it cannot be a list"
|
||||
name = self._name
|
||||
|
||||
if config.is_mandatory() and child.is_mandatory() and \
|
||||
((self.is_multi() and value == []) or
|
||||
(not self.is_multi() and value is None)):
|
||||
raise MandatoryError('cannot override value to %s for '
|
||||
'option %s' % (value, name))
|
||||
if name not in config._cfgimpl_values:
|
||||
raise AttributeError('unknown option %s' % (name))
|
||||
if config.is_frozen() and (child.has_callback() or child.isfrozen()):
|
||||
raise ConflictConfigError('cannot override value to %s for '
|
||||
'option %s' % (value, name))
|
||||
# we want the possibility to reset everything
|
||||
if who == "default" and value is None:
|
||||
self.default = None
|
||||
return
|
||||
if not self.validate(value):
|
||||
raise ConfigError('invalid value %s for option %s' % (value, name))
|
||||
if self.is_mandatory():
|
||||
# value shall not be '' for a mandatory option
|
||||
# so '' is considered as being None
|
||||
if value == '':
|
||||
value = None
|
||||
if config.is_mandatory() and ((self.is_multi() and value == []) or
|
||||
(not self.is_multi() and value is None)):
|
||||
raise MandatoryError('cannot override value to %s for '
|
||||
'option %s' % (value, name))
|
||||
if name not in config._cfgimpl_values:
|
||||
raise AttributeError('unknown option %s' % (name))
|
||||
if config.is_frozen() and (self.has_callback() or self.isfrozen()):
|
||||
raise ConflictConfigError('cannot override value to %s for '
|
||||
'option %s' % (value, name))
|
||||
if who == "default":
|
||||
# changes the default value (and therefore resets the previous value)
|
||||
if self._validate(value):
|
||||
@ -240,7 +244,7 @@ class Option(HiddenBaseType, DisabledBaseType):
|
||||
def unfreeze(self):
|
||||
self._frozen = False
|
||||
|
||||
def isfrozen(self):
|
||||
def is_frozen(self):
|
||||
return self._frozen
|
||||
# ____________________________________________________________
|
||||
def is_multi(self):
|
||||
@ -527,6 +531,7 @@ def apply_requires(opt, config):
|
||||
if action not in available_actions:
|
||||
raise RequiresError("malformed requirements"
|
||||
" for option: {0}".format(opt._name))
|
||||
# FIXME generic programming opt.property_launch(action, False)
|
||||
getattr(opt, action)() #.hide() or show() or...
|
||||
matches = True
|
||||
else: # option doesn't exist ! should not happen...
|
||||
|
Loading…
Reference in New Issue
Block a user