diff --git a/test/test_option.py b/test/test_option.py index ea5e603..585f304 100644 --- a/test/test_option.py +++ b/test/test_option.py @@ -98,6 +98,16 @@ def test_option_isoptiondescription(): assert not cfg.option('od.test').option.isoptiondescription() +def test_option_double(): + i = IntOption('test', '') + od = OptionDescription('od1', '', [i]) + od = OptionDescription('od2', '', [od]) + od = OptionDescription('od3', '', [od]) + cfg = Config(od) + assert cfg.option('od2.od1.test').value.get() is None + assert cfg.option('od2').option('od1').option('test').value.get() is None + + def test_option_multi(): IntOption('test', '', multi=True) IntOption('test', '', multi=True, default_multi=1) diff --git a/tiramisu/api.py b/tiramisu/api.py index 05fb482..a273805 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -203,6 +203,20 @@ class _TiramisuOptionOptionDescription(CommonTiramisuOption): settings.get_context_properties(), settings.get_context_properties()) + def __call__(self, + path: str, + index: Optional[int]=None) -> 'TiramisuOption': + """Select an option by path""" + subpath = self._option_bag.option.impl_getname() + '.' + path + subconfig, name = self._subconfig.cfgimpl_get_home_by_path(subpath, + self._option_bag.config_bag) + path = self._option_bag.path + '.' + path + return TiramisuOption(name, + path, + index, + subconfig, + self._option_bag.config_bag) + class _TiramisuOptionOption(_TiramisuOptionOptionDescription): """Manage option""" @@ -738,17 +752,9 @@ class TiramisuOption(CommonTiramisuOption): subconfig=subconfig, config_bag=config_bag) + #__________________________________________________________________________________________________ # -# First part of API: -# - contexts informations: -# - context owner -# - context information -# - context property -# - context permissive -# - forcepermissive -# - unrestraint -# - manage MetaConfig or GroupConfig class TiramisuContext(TiramisuHelp):