From 69f0a5454c6eb1471ef9d9b88b7f91b8f6072dff Mon Sep 17 00:00:00 2001 From: Daniil Anfimov Date: Fri, 24 Jun 2022 14:50:14 +0200 Subject: [PATCH] Added context manager --- cas_wrapper.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cas_wrapper.py b/cas_wrapper.py index 3e1cffa..e4bd8af 100644 --- a/cas_wrapper.py +++ b/cas_wrapper.py @@ -30,6 +30,18 @@ class CasWrapper: self._cas = local['cas'] self._cas['login']() + def __enter__(self): + with local.env( + CAS_API_KEY=self._cas_api_key, + SIGNER_ID=self._cas_signer_id, + ): + self._cas = local['cas'] + self._cas['login']() + return self + + def __exit__(self, exc_type, value, traceback): + self._cas['logout']() + def notarize( self, local_path: str,