Skip to content

Commit

Permalink
Add get data dir function to ConfigManager (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangmot authored and nightlark committed Dec 11, 2024
1 parent c2a0e07 commit d0e2c66
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions surfactant/configmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,16 @@ def delete_instance(cls, app_name: str) -> None:
with cls._lock:
if app_name in cls._instances:
del cls._instances[app_name]

def get_data_dir_path(self) -> Path:
"""Determines the path to the data directory, for storing things such as databases.
Returns:
Path: The path to the data directory.
"""
if platform.system() == "Windows":
data_dir = Path(os.getenv("LOCALAPPDATA", os.path.expanduser("~\\AppData\\Local")))
else:
data_dir = Path(os.getenv("XDG_DATA_HOME", os.path.expanduser("~/.local/share")))
data_dir = data_dir / self.app_name
return data_dir

0 comments on commit d0e2c66

Please sign in to comment.