Skip to content

Commit

Permalink
Read XDG_DATA_HOME only if JUJU_DATA is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
freyes committed Jan 2, 2024
1 parent b743472 commit f05162e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions juju/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ def juju_config_dir():
config_dir = Path('~/.local/share/juju')

# Check $JUJU_DATA
juju_data = os.environ.get('JUJU_DATA')
if os.environ.get('JUJU_DATA'):
config_dir = Path(os.environ.get('JUJU_DATA'))
# Secondly check: $XDG_DATA_HOME for ~/.local/share
xdg_data_home = os.environ.get('XDG_DATA_HOME')
if juju_data:
config_dir = Path(juju_data)
elif xdg_data_home:
config_dir = Path(xdg_data_home) / 'juju'
elif os.environ.get('XDG_DATA_HOME'):
config_dir = Path(os.environ.get('XDG_DATA_HOME')) / 'juju'

return str(config_dir.expanduser().resolve())

Expand Down

0 comments on commit f05162e

Please sign in to comment.