diff --git a/requirements.txt b/requirements.txt index 5119439f..6c6165b7 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +beautifulsoup4>=4.6.0 botocore>=1.12.36 +platformdirs>=2.4.0 # This can be bumped after Python 3.6 is deprecated. requests>=2.19.0 -beautifulsoup4>=4.6.0 diff --git a/setup.py b/setup.py index b28a832a..c2fbfef8 100755 --- a/setup.py +++ b/setup.py @@ -20,8 +20,11 @@ required = f.read().splitlines() about = {} -with open(os.path.join(here, "tokendito", "__init__.py"), "r") as f: - exec(f.read(), about) +with open(os.path.join(here, "tokendito", "__init__.py")) as f: + for line in f: + if line.startswith("__"): + split_line = line.strip().split(" = ") + about[split_line[0]] = "".join(split_line[1:]).replace('"', "") if "DEVBUILD" in os.environ: now = datetime.datetime.now() diff --git a/tokendito/__init__.py b/tokendito/__init__.py index c66994fe..bfb224b4 100644 --- a/tokendito/__init__.py +++ b/tokendito/__init__.py @@ -6,6 +6,8 @@ from os.path import expanduser import sys +from platformdirs import user_config_dir + __version__ = "2.0.0" __title__ = "tokendito" __description__ = "Get AWS STS tokens from Okta SSO" @@ -22,8 +24,10 @@ class Config(object): # Instantiated objects can get Class defaults with get_defaults() _defaults = dict( user=dict( - config_dir=os.path.join(expanduser("~"), ".aws"), - config_file=os.path.join(expanduser("~"), ".aws", "okta_auth"), + config_dir=user_config_dir(appname=__title__, appauthor=False), + config_file=os.path.join( + user_config_dir(appname=__title__, appauthor=False), f"{__title__}.ini" + ), config_profile="default", encoding=sys.stdin.encoding, loglevel="INFO", diff --git a/tokendito/user.py b/tokendito/user.py index 85f83f57..d3014b2d 100644 --- a/tokendito/user.py +++ b/tokendito/user.py @@ -90,7 +90,7 @@ def parse_cli_args(args): "--config-file", dest="user_config_file", default=config.user["config_file"], - help="Use an alternative configuration file", + help=f"Use an alternative configuration file. Defaults to {config.user['config_file']}", ) parser.add_argument( "--loglevel",