Skip to content

Commit

Permalink
using the localappdata environment variable for windows when getting …
Browse files Browse the repository at this point in the history
…the path to the user config file. I'm hoping this will be more reliable when you can do some unusual stuff when setting the HOME directory on windows.
  • Loading branch information
Eric Lefebvre committed Nov 8, 2017
1 parent 331d664 commit f335f8e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions envipyengine/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,18 @@ def _user_config_file():
:return: String specifying the full path to the settings.cfg file
"""
user_dir = os.path.expanduser('~')
if sys.platform == 'win32':
config_path = os.path.sep.join([user_dir, 'AppData', 'Local',
_APP_DIRNAME, _CONFIG_FILENAME])
if 'LOCALAPPDATA' in os.environ:
user_dir = os.getenv('LOCALAPPDATA')
else:
user_dir = os.path.join(os.path.expanduser('~'), 'AppData', 'Local')
config_path = os.path.join(user_dir, _APP_DIRNAME, _CONFIG_FILENAME)
elif sys.platform.startswith('darwin'):
user_dir = os.path.expanduser('~')
config_path = os.path.sep.join([user_dir, 'Library', 'Preferences',
_APP_DIRNAME, _CONFIG_FILENAME])
else:
user_dir = os.path.expanduser('~')
config_path = os.path.sep.join([user_dir, '.' + _APP_DIRNAME,
_CONFIG_FILENAME])
return config_path
Expand Down

0 comments on commit f335f8e

Please sign in to comment.