Skip to content

Instantly share code, notes, and snippets.

@lukacat10
Created April 29, 2024 00:18
Show Gist options
  • Save lukacat10/80e30f8ca2a5595afcc6367651794721 to your computer and use it in GitHub Desktop.
Save lukacat10/80e30f8ca2a5595afcc6367651794721 to your computer and use it in GitHub Desktop.
Common program data saving directory.
from pathlib import Path
import platform
PROGRAM_DIRECTORY_NAME = "AppName"
def get_program_data_path() -> Path:
path = None
if platform.system() == "Windows":
path = Path.home() / "AppData" / "Roaming" / PROGRAM_DIRECTORY_NAME
elif platform.system() == "Linux":
path = Path.home() / ".local" / "share" / PROGRAM_DIRECTORY_NAME
else:
raise RuntimeError("Platform not supported")
path.mkdir(parents=True, exist_ok=True)
return path
@lukacat10
Copy link
Author

Public due to low attack surface

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment