From 803d07a738da9e9f3b085c7ec3ddbdcf79c53905 Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Thu, 5 Oct 2017 17:20:37 +0200 Subject: [PATCH] config: Allow usage as a context manager --- weboob/tools/config/iconfig.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/weboob/tools/config/iconfig.py b/weboob/tools/config/iconfig.py index 119cfe1f81..9ae681043e 100644 --- a/weboob/tools/config/iconfig.py +++ b/weboob/tools/config/iconfig.py @@ -69,3 +69,9 @@ def get(self, *args, **kwargs): :param default: if specified, default value when path is not found """ raise NotImplementedError() + + def __enter__(self): + self.load() + + def __exit__(self, t, v, tb): + self.save() -- GitLab