Skip to content

Commit

Permalink
changed some constant names
Browse files Browse the repository at this point in the history
  • Loading branch information
aschroed committed Nov 5, 2022
1 parent b41dd74 commit 98ce013
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion tests/test_get_field_info.py
Expand Up @@ -163,7 +163,8 @@ def test_key_no_keyfile(capsys):
def test_key_error_wrong_format(capsys):
gfi.FDN_Key([("key_name", "my_key")], "key_name")
out = capsys.readouterr()[0]
message =f"The keyfile [('key_name', 'my_key')] does not exist\ncheck the --keyfile path or add {DEFAULT_KEYPAIR_FILE} to {CONFDIR}"
message = (f"The keyfile [('key_name', 'my_key')] does not exist\n"
f"check the --keyfile path or add {DEFAULT_KEYPAIR_FILE} to {CONFDIR}")
assert out.strip() == message


Expand Down
2 changes: 1 addition & 1 deletion wranglertools/constants.py
Expand Up @@ -10,7 +10,7 @@
HOME = pp.Path.home()
CONFDIR = HOME.joinpath('.submit4dn')
DEFAULT_KEYPAIR_FILE = 'keypairs.json'
ENV_VAR_DIR = 'SUBMIT_4DN_CONF_DIR'
CONFDIR_ENVVAR = 'SUBMIT_4DN_CONFDIR'

SHEET_ORDER = [
"User", "Award", "Lab", "Document", "Protocol", "ExperimentType",
Expand Down
8 changes: 4 additions & 4 deletions wranglertools/get_field_info.py
Expand Up @@ -11,7 +11,7 @@
import json

from wranglertools.constants import (
HOME, CONFDIR, ENV_VAR_DIR, DEFAULT_KEYPAIR_FILE, SHEET_ORDER
HOME, CONFDIR, CONFDIR_ENVVAR, DEFAULT_KEYPAIR_FILE, SHEET_ORDER
)


Expand Down Expand Up @@ -108,12 +108,12 @@ def __init__(self, keyfile, keyname):
then look there for the keys first
- using keyname if provided or
- look for a "default" entry if not
2) check to see if the ENV_VAR_DIR env variable is set and in this
2) check to see if the CONFDIR_ENVVAR env variable is set and in this
case we expect to find a file named keypairs.json with keys
to use there where we will look for key named keyname or "default"
3) finally look for keypairs.json in the .submit4dn directory and in home
directory
'''
'''
self.error = False
keys = None
default_location = CONFDIR.joinpath(DEFAULT_KEYPAIR_FILE)
Expand All @@ -130,7 +130,7 @@ def __init__(self, keyfile, keyname):
self.set_error(msg)
return
else: # default keyfile arg has been passed
envdir = os.environ.get(p ENV_VAR_DIR)
envdir = os.environ.get(CONFDIR_ENVVAR)
if envdir: # loc of keypairs.json specified in env var
fpath = pp.Path(envdir).joinpath(DEFAULT_KEYPAIR_FILE)
if not fpath.is_file():
Expand Down
4 changes: 2 additions & 2 deletions wranglertools/import_data.py
Expand Up @@ -26,7 +26,7 @@
from gspread.exceptions import GSpreadException
from openpyxl.utils.exceptions import InvalidFileException
from wranglertools.constants import (
CONFDIR, SHEET_ORDER, LIST_OF_LOADXL_FIELDS, ENV_VAR_DIR, GCRED_FNAME,
CONFDIR, SHEET_ORDER, LIST_OF_LOADXL_FIELDS, CONFDIR_ENVVAR, GCRED_FNAME,
AUTH_TOKEN_FNAME, SCOPES, GSHEET, EXCEL, ZIP_MIME, XLSX_MIME, ALLOWED_MIMES,
GSHEET_URL_REGEX, GSID_REGEX
)
Expand Down Expand Up @@ -129,7 +129,7 @@ class WebFetchException(Exception):

def google_authenticate():
gsauth = None
ga_cred_env = os.environ.get(ENV_VAR_DIR) # look to see if set as env variable
ga_cred_env = os.environ.get(CONFDIR_ENVVAR) # look to see if set as env variable
# default to .submit4dn dir in home dir
creddir = pp.Path(ga_cred_env) if ga_cred_env else CONFDIR
try:
Expand Down

0 comments on commit 98ce013

Please sign in to comment.