From 7f29b56934f7857beb950bda01a69ba5033289ba Mon Sep 17 00:00:00 2001 From: Gionata Biavati Date: Thu, 20 Sep 2018 09:23:57 +0100 Subject: added __enter__ and __exit__ methods --- cdsapi/api.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cdsapi/api.py') diff --git a/cdsapi/api.py b/cdsapi/api.py index 9160916..4823bd6 100644 --- a/cdsapi/api.py +++ b/cdsapi/api.py @@ -149,6 +149,13 @@ class Client(object): logger = logging.getLogger('cdsapi') + def __enter__(self, **kwargs): + self.__init__(**kwargs) + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + pass + def __init__(self, url=os.environ.get('CDSAPI_URL'), key=os.environ.get('CDSAPI_KEY'), -- cgit v1.2.3