callback with option in params which is in an hidden optiondescription
This commit is contained in:
@ -49,7 +49,7 @@ def carry_out_calculation(name, config, callback, callback_params, index=None):
|
||||
raise ConfigError(_('no config specified but needed'))
|
||||
try:
|
||||
opt_value = config._getattr(path, force_permissive=True)
|
||||
opt = config.unwrap_from_path(path)
|
||||
opt = config.unwrap_from_path(path, force_permissive=True)
|
||||
except PropertiesOptionError, err:
|
||||
if check_disabled:
|
||||
continue
|
||||
|
@ -351,32 +351,32 @@ class SubConfig(BaseInformation):
|
||||
|
||||
def make_dict(self, flatten=False, _currpath=None, withoption=None,
|
||||
withvalue=None):
|
||||
"""exports the whole config into a `dict`, for example:
|
||||
|
||||
"""exports the whole config into a `dict`, for example:
|
||||
|
||||
>>> print cfg.make_dict()
|
||||
{'od2.var4': None, 'od2.var5': None, 'od2.var6': None}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:param flatten: returns a dict(name=value) instead of a dict(path=value)
|
||||
::
|
||||
|
||||
>>> print cfg.make_dict(flatten=True)
|
||||
{'var5': None, 'var4': None, 'var6': None}
|
||||
|
||||
|
||||
:param withoption: returns the options that are present in the very same
|
||||
`OptionDescription` than the `withoption` itself::
|
||||
|
||||
>>> print cfg.make_dict(withoption='var1')
|
||||
{'od2.var4': None, 'od2.var5': None, 'od2.var6': None,
|
||||
'od2.var1': u'value', 'od1.var1': None,
|
||||
{'od2.var4': None, 'od2.var5': None, 'od2.var6': None,
|
||||
'od2.var1': u'value', 'od1.var1': None,
|
||||
'od1.var3': None, 'od1.var2': None}
|
||||
|
||||
:param withvalue: returns the options that have the value `withvalue`
|
||||
::
|
||||
|
||||
>>> print c.make_dict(withoption='var1', withvalue=u'value')
|
||||
{'od2.var4': None, 'od2.var5': None, 'od2.var6': None,
|
||||
{'od2.var4': None, 'od2.var5': None, 'od2.var6': None,
|
||||
'od2.var1': u'value'}
|
||||
|
||||
:returns: dict of Option's name (or path) and values
|
||||
@ -466,7 +466,7 @@ class CommonConfig(SubConfig):
|
||||
opt = self.cfgimpl_get_description().impl_get_opt_by_path(path)
|
||||
return self.cfgimpl_get_values().getowner(opt)
|
||||
|
||||
def unwrap_from_path(self, path):
|
||||
def unwrap_from_path(self, path, force_permissive=False):
|
||||
"""convenience method to extract and Option() object from the Config()
|
||||
and it is **fast**: finds the option directly in the appropriate
|
||||
namespace
|
||||
@ -474,7 +474,8 @@ class CommonConfig(SubConfig):
|
||||
:returns: Option()
|
||||
"""
|
||||
if '.' in path:
|
||||
homeconfig, path = self.cfgimpl_get_home_by_path(path)
|
||||
homeconfig, path = self.cfgimpl_get_home_by_path(path,
|
||||
force_permissive=force_permissive)
|
||||
return getattr(homeconfig.cfgimpl_get_description(), path)
|
||||
return getattr(self.cfgimpl_get_description(), path)
|
||||
|
||||
|
Reference in New Issue
Block a user