From ef5bcbf98bbd2ce91f223a2766e9699fc3438db2 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 28 Apr 2016 11:31:04 +0200 Subject: [PATCH] user could delete informations set in config --- tiramisu/config.py | 3 +++ tiramisu/storage/dictionary/value.py | 7 +++++++ tiramisu/value.py | 7 +++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tiramisu/config.py b/tiramisu/config.py index 19b55c2..6cc8e4d 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -606,6 +606,9 @@ class _CommonConfig(SubConfig): """ return self._impl_values.get_information(key, default) + def impl_del_information(self, key, raises=True): + self._impl_values.del_information(key, raises) + # ----- state def __getstate__(self): if self._impl_meta is not None: diff --git a/tiramisu/storage/dictionary/value.py b/tiramisu/storage/dictionary/value.py index d77afa9..64fa42d 100644 --- a/tiramisu/storage/dictionary/value.py +++ b/tiramisu/storage/dictionary/value.py @@ -235,6 +235,13 @@ class Values(Cache): " not found: {0}").format(key)) return value + def del_information(self, key, raises): + if key in self._informations: + del(self._informations[key]) + else: + if raises: + raise ValueError(_("information's item not found {0}").format(key)) + def exportation(self, session, fake=False): return self._values diff --git a/tiramisu/value.py b/tiramisu/value.py index c780640..0c7d7ec 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -113,7 +113,7 @@ class Values(object): force_default = 'frozen' in self_properties and \ 'force_default_on_freeze' in self_properties # not default value - is_default = self._is_default_owner(opt, path, session, + is_default = self._is_default_owner(opt, path, session, validate_properties=False, validate_meta=False, self_properties=self_properties, @@ -558,7 +558,7 @@ class Values(object): :return: boolean """ path = opt.impl_getpath(self._getcontext()) - return self._is_default_owner(opt, path, session=None, + return self._is_default_owner(opt, path, session=None, validate_properties=validate_properties, validate_meta=validate_meta, index=index, force_permissive=force_permissive) @@ -599,6 +599,9 @@ class Values(object): """ return self._p_.get_information(key, default) + def del_information(self, key, raises=True): + self._p_.del_information(key, raises) + def mandatory_warnings(self, force_permissive=False, validate=True): """convenience function to trace Options that are mandatory and where no value has been set