now we know wich property has been matched
This commit is contained in:
parent
d8370b008b
commit
9bb366bb91
|
@ -188,16 +188,18 @@ class Config(object):
|
||||||
def _validate(self, name, opt_or_descr):
|
def _validate(self, name, opt_or_descr):
|
||||||
apply_requires(opt_or_descr, self)
|
apply_requires(opt_or_descr, self)
|
||||||
if not type(opt_or_descr) == OptionDescription:
|
if not type(opt_or_descr) == OptionDescription:
|
||||||
# hidden or disabled options
|
|
||||||
# XXX let's have a group with a hidden property
|
|
||||||
# and an option with a disabled property,
|
|
||||||
# then it matches anyway... is it important to fix this ?
|
|
||||||
if self._cfgimpl_toplevel._cfgimpl_has_properties() and \
|
if self._cfgimpl_toplevel._cfgimpl_has_properties() and \
|
||||||
(opt_or_descr.has_properties() or \
|
opt_or_descr.has_properties():
|
||||||
|
raise PropertiesOptionError("trying to access"
|
||||||
|
" to an option named: {0}".format(name),
|
||||||
|
opt_or_descr.properties))
|
||||||
|
if self._cfgimpl_toplevel._cfgimpl_has_properties() and \
|
||||||
self._cfgimpl_descr.has_properties()):
|
self._cfgimpl_descr.has_properties()):
|
||||||
raise PropertiesOptionError("trying to access to the option: {0} "
|
raise PropertiesOptionError("trying to access"
|
||||||
"with properties: {1}".format(name,
|
" to an option's group named: {0}"
|
||||||
str(opt_or_descr.properties)))
|
" for option named: {1}".format(
|
||||||
|
self._cfgimpl_descr._name, name),
|
||||||
|
self._cfgimpl_descr.properties)
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
# attribute access by passing a path,
|
# attribute access by passing a path,
|
||||||
|
@ -223,7 +225,8 @@ class Config(object):
|
||||||
# options with callbacks (fill or auto)
|
# options with callbacks (fill or auto)
|
||||||
if opt_or_descr.has_callback():
|
if opt_or_descr.has_callback():
|
||||||
value = self._cfgimpl_values[name]
|
value = self._cfgimpl_values[name]
|
||||||
if value != None:
|
if (not opt_or_descr.is_frozen() or \
|
||||||
|
not opt_or_descr.is_forced_on_freeze()) and value != None:
|
||||||
if opt_or_descr.is_multi():
|
if opt_or_descr.is_multi():
|
||||||
if None not in value:
|
if None not in value:
|
||||||
return value
|
return value
|
||||||
|
|
|
@ -7,7 +7,10 @@ class ConfigError(Exception):
|
||||||
class ConflictConfigError(ConfigError):
|
class ConflictConfigError(ConfigError):
|
||||||
pass
|
pass
|
||||||
class PropertiesOptionError(AttributeError):
|
class PropertiesOptionError(AttributeError):
|
||||||
pass
|
def __init__(self, msg, proptype=None):
|
||||||
|
self.proptype = proptype
|
||||||
|
super(PropertiesOptionError, self).__init__(msg)
|
||||||
|
|
||||||
class NotFoundError(Exception):
|
class NotFoundError(Exception):
|
||||||
pass
|
pass
|
||||||
class MethodCallError(Exception):
|
class MethodCallError(Exception):
|
||||||
|
|
Loading…
Reference in New Issue