Do not fail on missing HOME environment to get config directory

Also use first the XDG_CONFIG_HOME and fallback to expanduser.
This commit is contained in:
Cédric Krier committed 2022-04-18 19:32:26 +02:00
1 parent 4ace953e69
commit 6dfb8cecac
1 file changed
+3 -2
+3 -2
View File
@@ -22,8 +22,9 @@ def get_config_dir():
appdata = str(appdata, sys.getfilesystemencoding())
return os.path.join(appdata, '.config', 'tryton',
__version__.rsplit('.', 1)[0])
return os.path.join(os.environ['HOME'], '.config', 'tryton',
__version__.rsplit('.', 1)[0])
config_path = os.getenv('XDG_CONFIG_HOME', os.path.join('~', '.config'))
return os.path.expanduser(
os.path.join(config_path, 'tryton', __version__.rsplit('.', 1)[0]))
if not os.path.isdir(get_config_dir()):