This repository was archived by the owner on Apr 30, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-17
lines changed Expand file tree Collapse file tree 2 files changed +14
-17
lines changed Original file line number Diff line number Diff line change
1
+ import os
2
+
3
+
1
4
class ApiConfig :
2
5
api_key = None
3
6
api_protocol = 'https://'
@@ -14,8 +17,7 @@ class ApiConfig:
14
17
15
18
def save_key (apikey , filename = None ):
16
19
if filename is None :
17
- import pathlib
18
- filename = str (pathlib .Path .home ()) + "/.quandl_apikey"
20
+ filename = os .path .join (os .path .expanduser ('~' ), '.quandl_apikey' )
19
21
20
22
fileptr = open (filename , 'w' )
21
23
fileptr .write (apikey )
@@ -25,17 +27,12 @@ def save_key(apikey, filename=None):
25
27
26
28
def read_key (filename = None ):
27
29
if filename is None :
28
- import pathlib
29
- filename = str (pathlib .Path .home ()) + "/.quandl_apikey"
30
-
31
- try :
32
- fileptr = open (filename , 'r' )
33
- apikey = fileptr .read ()
34
- fileptr .close ()
35
-
36
- if apikey :
37
- ApiConfig .api_key = apikey
38
- else :
39
- raise Exception ("File '{:s}' is empty." .format (filename ))
40
- except ValueError :
41
- raise Exception ("File '{:s}' not found." .format (filename ))
30
+ filename = os .path .join (os .path .expanduser ('~' ), '.quandl_apikey' )
31
+
32
+ with open (filename , 'r' ) as f :
33
+ apikey = f .read ()
34
+
35
+ if not apikey :
36
+ raise ValueError ("File '{:s}' is empty." .format (filename ))
37
+
38
+ ApiConfig .api_key = apikey
Original file line number Diff line number Diff line change 1
- VERSION = '3.4.5 '
1
+ VERSION = '3.4.6 '
You can’t perform that action at this time.
0 commit comments