Extract the storage layer into core

This commit is contained in:
2026-09-21 14:20:51 -04:00
parent 87757aaaf9
commit 518f8b80ae
43 changed files with 5247 additions and 5010 deletions
+19 -10
View File
@@ -1,20 +1,29 @@
"""SQLite storage path resolution for the NestQuest integration."""
"""Re-export of :mod:`core.store` for the integration package.
The path resolver lives in :mod:`core.store` (extracted in task
d0b691d8) and is Home-Assistant-free: :func:`core.store.async_get_db_path`
takes the full database path. This module re-exports it and provides
the original ``async_get_db_path(hass)`` signature so the integration
resolves the path from ``hass.config.path`` exactly as before.
"""
from __future__ import annotations
from pathlib import Path
from homeassistant.core import HomeAssistant
from .const import SQLITE_DB_FILENAME
from core.const import SQLITE_DB_FILENAME
from core.store import async_get_db_path as _core_async_get_db_path
from core.store import _ensure_dir
def _ensure_dir(path: Path) -> None:
"""Create the given directory and any missing parents."""
path.mkdir(parents=True, exist_ok=True)
__all__ = ["async_get_db_path", "_ensure_dir"]
async def async_get_db_path(hass: HomeAssistant) -> Path:
"""Return the absolute path to the NestQuest SQLite database file."""
db_path = Path(hass.config.path(SQLITE_DB_FILENAME)).absolute()
await hass.async_add_executor_job(_ensure_dir, db_path.parent)
return db_path
"""Return the absolute path to the NestQuest SQLite database file.
Resolves the database file from ``hass.config.path`` and delegates to
:func:`core.store.async_get_db_path`, which ensures the parent
directory exists off the event loop via :func:`asyncio.to_thread`.
"""
return await _core_async_get_db_path(hass.config.path(SQLITE_DB_FILENAME))