core: use appdirs for ~/.config detection
This commit is contained in:
parent
b2b7eee480
commit
8f86d7706b
1 changed files with 2 additions and 3 deletions
|
@ -30,6 +30,7 @@ def setup_config() -> None:
|
||||||
import os
|
import os
|
||||||
import warnings
|
import warnings
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
import appdirs # type: ignore[import]
|
||||||
|
|
||||||
# not sure if that's necessary, i.e. could rely on PYTHONPATH instead
|
# 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?
|
# 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:
|
if mvar is not None:
|
||||||
mycfg_dir = Path(mvar)
|
mycfg_dir = Path(mvar)
|
||||||
else:
|
else:
|
||||||
# TODO use appdir??
|
mycfg_dir = Path(appdirs.user_config_dir('my'))
|
||||||
cfg_dir = Path('~/.config').expanduser()
|
|
||||||
mycfg_dir = cfg_dir / 'my'
|
|
||||||
|
|
||||||
if not mycfg_dir.exists():
|
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.")
|
warnings.warn(f"my.config package isn't found! (expected at {mycfg_dir}). This is likely to result in issues.")
|
||||||
|
|
Loading…
Add table
Reference in a new issue