diff --git a/test/test_option_calculation.py b/test/test_option_calculation.py index 9196b7b..2230fba 100644 --- a/test/test_option_calculation.py +++ b/test/test_option_calculation.py @@ -487,3 +487,14 @@ def test_callback_master_and_slaves_value(): assert cfg.val1.val2 == ['val2', 'val2', 'val3'] +def test_callback_hidden(): + opt1 = BoolOption('opt1', '') + opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': (('od1.opt1', False),)}) + od1 = OptionDescription('od1', '', [opt1], properties=('hidden',)) + od2 = OptionDescription('od2', '', [opt2]) + maconfig = OptionDescription('rootconfig', '', [od1, od2]) + cfg = Config(maconfig) + cfg.cfgimpl_get_settings().set_permissive(('hidden',)) + cfg.read_write() + raises(PropertiesOptionError, 'cfg.od1.opt1') + cfg.od2.opt2 diff --git a/tiramisu/autolib.py b/tiramisu/autolib.py index 0d700c3..6ba1dfd 100644 --- a/tiramisu/autolib.py +++ b/tiramisu/autolib.py @@ -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 diff --git a/tiramisu/config.py b/tiramisu/config.py index 9587e69..7152ea6 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -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)