diff options
author | Gionata Biavati <Gionata.Biavati@ecmwf.int> | 2018-05-22 10:33:03 +0100 |
---|---|---|
committer | Gionata Biavati <Gionata.Biavati@ecmwf.int> | 2018-05-22 10:33:03 +0100 |
commit | 7a9489b18b5f873b6cb3cf8ac5e6b6cf2d8b01d4 (patch) | |
tree | b71867a9c9c9d35e2c4e7683ceae318f0c7f6a8e | |
parent | decccb5a484c014fbee04bf299f0739f24380076 (diff) |
badly shaped .cdsapirc files (with empty lines) were causing the api to fail. Now untill the information required is provided, we are ignoring the badly formatted lines
-rw-r--r-- | cdsapi/api.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cdsapi/api.py b/cdsapi/api.py index c15c84c..a53ebf0 100644 --- a/cdsapi/api.py +++ b/cdsapi/api.py @@ -48,8 +48,12 @@ class Client(object): config = {} with open(dotrc) as f: for l in f.readlines(): + try: k, v = l.strip().split(':', 1) - config[k] = v.strip() + if k in ['url', 'key']: + config[k] = v.strip() + except: + print('The file ~/.cdsapirc is badly formatted (remove extra lines not required)') url = config.get('url') key = config.get('key') |