Skip to content

Commit 7c242f6

Browse files
committed
Add file path
1 parent 23db56b commit 7c242f6

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

caltechdata_api/cli.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from .md_to_json import parse_readme_to_json
66
import json
77
import os
8-
9-
# import configparser
108
from cryptography.fernet import Fernet
119

1210
CALTECHDATA_API = "https://data.caltech.edu/api/names?q=identifiers.identifier:{}"
@@ -23,10 +21,6 @@
2321
funderIdentifierType = ""
2422
funderName = ""
2523

26-
27-
# CONFIG_FILE = "caltechdata_config.ini"
28-
29-
3024
home_directory = os.path.expanduser("~")
3125
caltechdata_directory = os.path.join(home_directory, ".caltechdata")
3226

@@ -40,7 +34,8 @@ def generate_key():
4034

4135

4236
# Load the key from a file or generate a new one if not present
43-
def load_or_generate_key(key_file="key.key"):
37+
def load_or_generate_key():
38+
key_file = os.path.join(caltechdata_directory, key_file)
4439
if os.path.exists(key_file):
4540
with open(key_file, "rb") as f:
4641
return f.read()
@@ -67,7 +62,8 @@ def decrypt_token(encrypted_token, key):
6762
def get_or_set_token():
6863
key = load_or_generate_key()
6964
try:
70-
with open("token.txt", "rb") as f:
65+
token = os.path.join(caltechdata_directory, "token.txt")
66+
with open(token, "rb") as f:
7167
encrypted_token = f.read()
7268
token = decrypt_token(encrypted_token, key)
7369
return token
@@ -255,7 +251,8 @@ def get_names(orcid):
255251

256252

257253
def write_s3cmd_config(access_key, secret_key):
258-
with open("~/.s3cfg", "w") as file:
254+
configf = os.path.join(home_directory, ".s3cfg")
255+
with open(configf, "w") as file:
259256
file.write(
260257
f"""[default]
261258
access_key = {access_key}

0 commit comments

Comments
 (0)