55from .md_to_json import parse_readme_to_json
66import json
77import os
8-
9- # import configparser
108from cryptography .fernet import Fernet
119
1210CALTECHDATA_API = "https://data.caltech.edu/api/names?q=identifiers.identifier:{}"
2321funderIdentifierType = ""
2422funderName = ""
2523
26-
27- # CONFIG_FILE = "caltechdata_config.ini"
28-
29-
3024home_directory = os .path .expanduser ("~" )
3125caltechdata_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):
6762def 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
257253def 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