From 77a77dd01c310571733a4106ff7d1eafea09633b Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 13 Sep 2018 09:17:38 +0200 Subject: [PATCH] new can create a metaconfig too --- tiramisu/api.py | 7 +++++-- tiramisu/config.py | 20 ++++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/tiramisu/api.py b/tiramisu/api.py index 77c127a..049b2ce 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -1001,8 +1001,11 @@ class TiramisuContextConfig(TiramisuContext): def _m_new(self, session_id, - persistent=False): - return Config(self.config_bag.context.new_config(session_id=session_id, persistent=persistent)) + persistent=False, + type='config'): + return Config(self.config_bag.context.new_config(session_id=session_id, + persistent=persistent, + type_=type)) def _m_pop(self, session_id): diff --git a/tiramisu/config.py b/tiramisu/config.py index aa04f50..1c945f1 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -1125,14 +1125,22 @@ class KernelMetaConfig(KernelGroupConfig): def new_config(self, session_id, + type_='config', persistent=False): - config = KernelConfig(self._impl_descr, - session_id=session_id, - persistent=persistent) - - if config._impl_name in [child._impl_name for child in self._impl_children]: # pragma: no cover + if session_id in [child._impl_name for child in self._impl_children]: # pragma: no cover raise ConflictError(_('config name must be uniq in ' - 'groupconfig for {0}').format(config._impl_name)) + 'groupconfig for {0}').format(session_id)) + if type_ == 'config': + config = KernelConfig(self._impl_descr, + session_id=session_id, + persistent=persistent) + elif type_ == 'metaconfig': + config = KernelMetaConfig([], + optiondescription=self._impl_descr, + session_id=session_id, + persistent=persistent) + else: + raise ConfigError(_('unknown type {}').format(type_)) # Copy context properties/permissives config.cfgimpl_get_settings().set_context_properties(self.cfgimpl_get_settings().get_context_properties(), config) config.cfgimpl_get_settings().set_context_permissives(self.cfgimpl_get_settings().get_context_permissives())