can remove config from a metaconfig

This commit is contained in:
Emmanuel Garette 2018-09-13 07:00:12 +02:00
parent ccf3f0ae06
commit 620eaa6461
4 changed files with 26 additions and 0 deletions

View File

@ -1,3 +1,7 @@
Sat Sep 8 22:54:12 2018 +0200 Emmanuel Garette <egarette@cadoles.com>
* propose a new API to access to Tiramisu Option
This new API is totally incompatible with older's one
Sat Jul 8 15:57:13 2017 +0200 Emmanuel Garette <egarette@cadoles.com> Sat Jul 8 15:57:13 2017 +0200 Emmanuel Garette <egarette@cadoles.com>
* better cache, only remove value/property from cache for value * better cache, only remove value/property from cache for value
modified and for all value affected by this modification modified and for all value affected by this modification

View File

@ -185,6 +185,17 @@ def test_meta_new_config():
assert len(list(meta.config.list())) == 3 assert len(list(meta.config.list())) == 3
def test_meta_pop_config():
od = make_description()
meta = MetaConfig(['name1', 'name2'], optiondescription=od)
assert len(list(meta.config.list())) == 2
meta.config.new('newconf1')
assert len(list(meta.config.list())) == 3
meta.config.pop('newconf1')
assert len(list(meta.config.list())) == 2
raises(ConfigError, "meta.config.pop('newconf1')")
def test_meta_new_config_wrong_name(): def test_meta_new_config_wrong_name():
od = make_description() od = make_description()
meta = MetaConfig(['name1', 'name2'], optiondescription=od) meta = MetaConfig(['name1', 'name2'], optiondescription=od)

View File

@ -1002,6 +1002,10 @@ class TiramisuContextConfig(TiramisuContext):
persistent=False): persistent=False):
return Config(self.config_bag.context.new_config(session_id=session_id, persistent=persistent)) return Config(self.config_bag.context.new_config(session_id=session_id, persistent=persistent))
def _m_pop(self,
session_id):
return Config(self.config_bag.context.pop_config(session_id=session_id))
def _m_list(self): def _m_list(self):
return self._g_list() return self._g_list()

View File

@ -1140,3 +1140,10 @@ class KernelMetaConfig(KernelGroupConfig):
config._impl_meta = weakref.ref(self) config._impl_meta = weakref.ref(self)
self._impl_children.append(config) self._impl_children.append(config)
return config return config
def pop_config(self,
session_id):
for idx, child in enumerate(self._impl_children): # pragma: no cover
if session_id == child._impl_name:
return self._impl_children.pop(idx)
raise ConfigError(_('cannot find the config {}').format(session_id))