From b0462a1e808554c978ff17fa10555837fa4417be Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 18 May 2021 18:52:42 +0200 Subject: [PATCH 1/2] . is no more unvalable --- tests/test_option.py | 12 ++++++++++++ tiramisu/option/baseoption.py | 2 ++ 2 files changed, 14 insertions(+) diff --git a/tests/test_option.py b/tests/test_option.py index 17bf65e..16d3c9e 100644 --- a/tests/test_option.py +++ b/tests/test_option.py @@ -31,6 +31,18 @@ async def test_option_valid_name(): with pytest.raises(ValueError): SymLinkOption(1, i) i = SymLinkOption("test1", i) +# +# +#@pytest.mark.asyncio +#async def test_option_unvalid_name(): +# with pytest.raises(ValueError): +# IntOption('test.', '') +# with pytest.raises(ValueError): +# IntOption('test.val', '') +# with pytest.raises(ValueError): +# IntOption('.test', '') +# with pytest.raises(ValueError): +# OptionDescription('.test', '', []) @pytest.mark.asyncio diff --git a/tiramisu/option/baseoption.py b/tiramisu/option/baseoption.py index c4e51ee..c682634 100644 --- a/tiramisu/option/baseoption.py +++ b/tiramisu/option/baseoption.py @@ -40,6 +40,8 @@ submulti = 2 def valid_name(name): if not isinstance(name, str): return False +# if '.' in name: +# return False return True From 64017d5cd4a42f1cffb83501371e15c72b061534 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 18 May 2021 18:53:14 +0200 Subject: [PATCH 2/2] import/export informations --- tiramisu/api.py | 13 ++++++++++++- tiramisu/autolib.py | 7 ++++--- tiramisu/storage/postgres/value.py | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tiramisu/api.py b/tiramisu/api.py index c1dd4e8..1448baa 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -484,7 +484,8 @@ class TiramisuOptionInformation(CommonTiramisuOption): @option_and_connection async def reset(self, - key): + key: str, + ) -> None: """Remove information""" path = self._option_bag.path values = self._option_bag.config_bag.context.cfgimpl_get_values() @@ -921,6 +922,16 @@ class TiramisuContextInformation(TiramisuConfig): """List information's keys""" return await self._config_bag.context.impl_list_information(self._config_bag.connection) + @connection + async def exportation(self): + """Export all informations""" + return await self._config_bag.context.cfgimpl_get_values()._p_.exportation_informations(self._config_bag.connection) + + @connection + async def importation(self, informations): + """Import informations""" + return await self._config_bag.context.cfgimpl_get_values()._p_.importation_informations(self._config_bag.connection, informations) + class TiramisuContextValue(TiramisuConfig): """Manage config value""" diff --git a/tiramisu/autolib.py b/tiramisu/autolib.py index 18f589a..9e4ac0c 100644 --- a/tiramisu/autolib.py +++ b/tiramisu/autolib.py @@ -358,10 +358,11 @@ async def manager_callback(callbk: Param, suffix = callbk.suffix else: if not option.impl_is_dynsymlinkoption(): - msg = 'option "{}" is not dynamic in callback of the option "{}"' - raise ConfigError(_(msg).format(callbk_option.impl_get_display_name(), - option.impl_get_display_name(), + msg = 'option "{}" is not dynamic but is an argument of the dynamic option "{}" in a callback' + raise ConfigError(_(msg).format(option.impl_get_display_name(), + callbk_option.impl_get_display_name(), )) + #FIXME in same dynamic option? rootpath = option.rootpath suffix = option.impl_getsuffix() subdyn = callbk_option.getsubdyn() diff --git a/tiramisu/storage/postgres/value.py b/tiramisu/storage/postgres/value.py index 2f3f5c5..7f18177 100644 --- a/tiramisu/storage/postgres/value.py +++ b/tiramisu/storage/postgres/value.py @@ -240,7 +240,9 @@ class Values: connection, informations, ): + await self.del_informations(connection) for path, path_infos in informations.items(): + path = self._storage.convert_path(path) for key, value in path_infos.items(): await connection.execute("INSERT INTO information(key, value, session_id, path) VALUES " "($1, $2, $3, $4)", key, dumps(value), self._storage.database_id, path)