diff options
Diffstat (limited to '')
-rw-r--r-- | muddle/paths.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/muddle/paths.py b/muddle/paths.py new file mode 100644 index 0000000..1448586 --- /dev/null +++ b/muddle/paths.py @@ -0,0 +1,32 @@ +import pathlib +import platform +import os + +default_config_dir = pathlib.Path.cwd() +default_log_dir = pathlib.Path.cwd() + +if platform.system() == "Linux": + # compliant with XDG + if os.environ.get("XDG_CONFIG_HOME"): + default_config_dir = pathlib.PurePath(os.environ["XDG_CONFIG_HOME"]).joinpath("muddle/") + + elif pathlib.Path("~/.config").expanduser().exists(): + default_config_dir = pathlib.Path("~/.config/muddle/").expanduser() + + if os.environ.get("XDG_CACHE_HOME"): + default_log_dir = pathlib.Path(os.environ["XDG_CACHE_HOME"]).joinpath("muddle/") + + elif pathlib.Path("~/.cache").expanduser().exists(): + default_log_dir = pathlib.Path("~/.cache/muddle/").expanduser() + +elif platform.system() == "Windows": + if os.environ.get("APPDATA"): + default_config_dir = pathlib.Path(os.environ["APPDATA"]).joinpath("muddle/") + + if os.environ.get("LOCALAPPDATA"): + default_log_dir = pathlib.Path(os.environ["LOCALAPPDATA"]).joinpath("muddle") + +# TODO: implement for MacOS + +default_config_file = default_config_dir.joinpath("muddle.ini") +default_log_file = default_log_dir.joinpath("muddle.log")
\ No newline at end of file |