summaryrefslogtreecommitdiff
path: root/cdsapi
diff options
context:
space:
mode:
Diffstat (limited to 'cdsapi')
-rw-r--r--cdsapi/__init__.py5
-rw-r--r--cdsapi/api.py11
2 files changed, 12 insertions, 4 deletions
diff --git a/cdsapi/__init__.py b/cdsapi/__init__.py
index e7cdf1b..c9e9d4e 100644
--- a/cdsapi/__init__.py
+++ b/cdsapi/__init__.py
@@ -16,7 +16,8 @@
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.
+from __future__ import absolute_import, division, print_function, unicode_literals
-import cdsapi.api
+from . import api
-Client = cdsapi.api.Client
+Client = api.Client
diff --git a/cdsapi/api.py b/cdsapi/api.py
index 3f3be34..7488002 100644
--- a/cdsapi/api.py
+++ b/cdsapi/api.py
@@ -6,12 +6,15 @@
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.
-import requests
+from __future__ import absolute_import, division, print_function, unicode_literals
+
import json
import time
import os
import logging
+import requests
+
def bytes_to_string(n):
u = ['', 'K', 'M', 'G', 'T', 'P']
@@ -45,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')