diff --git a/yeet_api/__init__.py b/yeet_api/__init__.py index d6ec208..73fcf0e 100644 --- a/yeet_api/__init__.py +++ b/yeet_api/__init__.py @@ -5,17 +5,26 @@ from pathlib import Path +_home_dir: str + +if os.name == "posix": + _home_dir = os.getenv("HOME", "") +elif os.name == "nt": + _home_dir = os.getenv("USERPROFILE", "") +else: + raise OSError("Unsupported OS: yeet-api only supports Windows and unix-like OSses.") + if not shutil.which("git"): raise FileNotFoundError("Git executable is not found." "\nFor Windows, install it from https://git-scm.com/downloads" "\nFor Linux, it is best to use your distro package manager. If " "for some reason you can't, use the link for Windows.") -_config_dir = Path(os.getenv("HOME", "")).joinpath(".config", "yeet") +_config_dir = Path(_home_dir).joinpath(".config", "yeet") if not _config_dir.exists(): os.makedirs(_config_dir, exist_ok=True) -_cache_dir = Path(os.getenv("HOME", "")).joinpath(".cache", "yeet") +_cache_dir = Path(_home_dir).joinpath(".cache", "yeet") if not _cache_dir.exists(): os.makedirs(_cache_dir, exist_ok=True)