now we know wich property has been matched

This commit is contained in:
gwen 2012-09-07 15:47:06 +02:00
parent d8370b008b
commit 9bb366bb91
2 changed files with 17 additions and 11 deletions

View File

@ -188,16 +188,18 @@ class Config(object):
def _validate(self, name, opt_or_descr):
apply_requires(opt_or_descr, self)
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 \
(opt_or_descr.has_properties() or \
self._cfgimpl_descr.has_properties()):
raise PropertiesOptionError("trying to access to the option: {0} "
"with properties: {1}".format(name,
str(opt_or_descr.properties)))
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()):
raise PropertiesOptionError("trying to access"
" to an option's group named: {0}"
" for option named: {1}".format(
self._cfgimpl_descr._name, name),
self._cfgimpl_descr.properties)
def __getattr__(self, name):
# attribute access by passing a path,
@ -223,7 +225,8 @@ class Config(object):
# options with callbacks (fill or auto)
if opt_or_descr.has_callback():
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 None not in value:
return value

View File

@ -7,7 +7,10 @@ class ConfigError(Exception):
class ConflictConfigError(ConfigError):
pass
class PropertiesOptionError(AttributeError):
pass
def __init__(self, msg, proptype=None):
self.proptype = proptype
super(PropertiesOptionError, self).__init__(msg)
class NotFoundError(Exception):
pass
class MethodCallError(Exception):