From 35ffde841b56c52cfe5dec6f527979cd91eb2ff8 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 7 Mar 2016 16:34:36 +0100 Subject: [PATCH] add force_permissive to Values.is_default_owner --- ChangeLog | 1 + test/test_option_owner.py | 8 ++++++++ tiramisu/value.py | 10 ++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index fc4aec4..e3c85ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ Mon Mar 7 16:10:30 2016 +0200 Emmanuel Garette * force_store_value is now used directly when configuration is loaded + * add force_permissive to Values.is_default_owner Sun Nov 29 23:01:28 2015 +0200 Emmanuel Garette * requires could be apply to a slave and properties could be different diff --git a/test/test_option_owner.py b/test/test_option_owner.py index b0b3359..6f88182 100644 --- a/test/test_option_owner.py +++ b/test/test_option_owner.py @@ -49,6 +49,12 @@ def test_hidden_owner(): cfg = Config(descr) cfg.read_write() raises(PropertiesOptionError, "cfg.getowner(gcdummy)") + raises(PropertiesOptionError, "cfg.getowner(gcdummy, force_permissive=True)") + raises(PropertiesOptionError, "cfg.cfgimpl_get_values().is_default_owner(gcdummy)") + raises(PropertiesOptionError, "cfg.cfgimpl_get_values().is_default_owner(gcdummy, force_permissive=True)") + cfg.cfgimpl_get_settings().setpermissive(('hidden',)) + cfg.getowner(gcdummy, force_permissive=True) + cfg.cfgimpl_get_values().is_default_owner(gcdummy, force_permissive=True) def test_addowner(): @@ -57,10 +63,12 @@ def test_addowner(): cfg = Config(descr) assert cfg.dummy is False assert cfg.getowner(gcdummy) == 'default' + assert cfg.cfgimpl_get_values().is_default_owner(gcdummy) owners.addowner("gen_config") cfg.cfgimpl_get_settings().setowner(owners.gen_config) cfg.dummy = True assert cfg.getowner(gcdummy) == owners.gen_config + assert not cfg.cfgimpl_get_values().is_default_owner(gcdummy) def test_addowner_multiple_time(): diff --git a/tiramisu/value.py b/tiramisu/value.py index e7dc6bb..8c32fbc 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -531,7 +531,8 @@ class Values(object): self._p_.setowner(path, owner, index=index) def is_default_owner(self, opt, validate_properties=True, - validate_meta=True, index=None): + validate_meta=True, index=None, + force_permissive=False): """ :param config: *must* be only the **parent** config (not the toplevel config) @@ -540,17 +541,18 @@ class Values(object): path = opt.impl_getpath(self._getcontext()) return self._is_default_owner(opt, path, validate_properties=validate_properties, - validate_meta=validate_meta, index=index) + validate_meta=validate_meta, index=index, + force_permissive=force_permissive) def _is_default_owner(self, opt, path, validate_properties=True, validate_meta=True, self_properties=undefined, - index=None): + index=None, force_permissive=False): if not opt.impl_is_master_slaves('slave'): index = None d = self._getowner(opt, path, validate_properties, validate_meta=validate_meta, self_properties=self_properties, only_default=True, - index=index) + index=index, force_permissive=force_permissive) return d == owners.default def reset_cache(self, only_expired):