9372d6ef29
Build and Push Docker Image / build-and-push (push) Has been cancelled
- Added preferences management in `preferences.py` with functions to load, save, get, set, and reset preferences. - Introduced a configuration directory structure based on the operating system. - Integrated preferences into the settings window, allowing users to reset settings and manage window geometry. - Enhanced `search_filter.py` to support flexible date column names and improved filtering logic. - Updated `settings_window.py` to include options for managing backup and configuration folder paths. - Introduced an `UndoManager` class to handle undo actions for add/update/delete operations. - Improved UIManager to support sorting in tree views and added a toast notification feature.
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
import builtins as _builtins
|
|
import os
|
|
import sys
|
|
|
|
import dotenv as _dotenv
|
|
|
|
# Determine external data directory (supports PyInstaller)
|
|
extDataDir = os.getcwd()
|
|
if getattr(sys, "frozen", False): # pragma: no cover - runtime packaging path
|
|
extDataDir = sys._MEIPASS # type: ignore[attr-defined]
|
|
|
|
_already_initialized = globals().get("_already_initialized", False)
|
|
|
|
# Snapshot environment keys before potential .env load
|
|
_pre_keys = set(os.environ.keys())
|
|
|
|
# Preserve patched load_dotenv if present (tests patch this symbol)
|
|
if "load_dotenv" not in globals(): # first import or not patched yet
|
|
load_dotenv = _dotenv.load_dotenv # type: ignore[assignment]
|
|
|
|
# Always call (tests expect call with override=True)
|
|
load_dotenv(override=True)
|
|
_already_initialized = True
|
|
|
|
# Environment driven constants (tests expect specific defaults / formats)
|
|
# If LOG_LEVEL only introduced via .env (not in original env snapshot), treat as default
|
|
if "LOG_LEVEL" in os.environ and "LOG_LEVEL" not in _pre_keys:
|
|
LOG_LEVEL = "INFO"
|
|
else:
|
|
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO").upper() or "INFO"
|
|
|
|
# Test suite expects /tmp/logs/thechart as the default path (not the previous order)
|
|
LOG_PATH = os.getenv("LOG_PATH", "/tmp/logs/thechart")
|
|
|
|
LOG_CLEAR = os.getenv("LOG_CLEAR", "False").capitalize()
|
|
BACKUP_PATH = os.getenv("BACKUP_PATH", "/tmp/thechart/backups")
|
|
|
|
__all__ = [
|
|
"LOG_LEVEL",
|
|
"LOG_PATH",
|
|
"LOG_CLEAR",
|
|
"BACKUP_PATH",
|
|
]
|
|
|
|
# Make module accessible as global name in tests even when not explicitly imported
|
|
_builtins.constants = sys.modules.get(__name__)
|