-
Notifications
You must be signed in to change notification settings - Fork 47
/
conf.py
38 lines (31 loc) · 1.17 KB
/
conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import platform
from pathlib import Path
PACKAGE_NAME = "algokit"
def get_app_config_dir() -> Path:
"""Get the application config files location - things that should persist, and potentially follow a user"""
os_type = platform.system().lower()
if os_type == "windows":
config_dir = os.getenv("APPDATA")
else:
config_dir = os.getenv("XDG_CONFIG_HOME")
if config_dir is None:
config_dir = "~/.config"
return _get_relative_app_path(config_dir)
def get_app_state_dir() -> Path:
"""Get the application state files location - things the user wouldn't normally interact with directly"""
os_type = platform.system().lower()
if os_type == "windows":
state_dir = os.getenv("LOCALAPPDATA")
elif os_type == "darwin":
state_dir = "~/Library/Application Support"
else:
state_dir = os.getenv("XDG_STATE_HOME")
if state_dir is None:
state_dir = "~/.local/state"
return _get_relative_app_path(state_dir)
def _get_relative_app_path(base_dir: str) -> Path:
path = Path(base_dir).expanduser()
result = path / PACKAGE_NAME
result.mkdir(parents=True, exist_ok=True)
return result