From 8f86d7706b8c59b98208f86760c24957b9b3fa6e Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Fri, 15 May 2020 07:57:51 +0100 Subject: [PATCH] core: use appdirs for ~/.config detection --- my/core/init.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/my/core/init.py b/my/core/init.py index e3a5e7a..4070f4d 100644 --- a/my/core/init.py +++ b/my/core/init.py @@ -30,6 +30,7 @@ def setup_config() -> None: import os import warnings from typing import Optional + import appdirs # type: ignore[import] # not sure if that's necessary, i.e. could rely on PYTHONPATH instead # on the other hand, by using MY_CONFIG we are guaranteed to load it from the desired path? @@ -37,9 +38,7 @@ def setup_config() -> None: if mvar is not None: mycfg_dir = Path(mvar) else: - # TODO use appdir?? - cfg_dir = Path('~/.config').expanduser() - mycfg_dir = cfg_dir / 'my' + mycfg_dir = Path(appdirs.user_config_dir('my')) if not mycfg_dir.exists(): warnings.warn(f"my.config package isn't found! (expected at {mycfg_dir}). This is likely to result in issues.")