221 files

This commit is contained in:
Home Assistant Version Control
2026-10-10 15:24:58 +00:00
parent ae12b88c7d
commit bfafb4c28a
221 changed files with 73725 additions and 3277 deletions
+21 -5
View File
@@ -11,11 +11,11 @@ if TYPE_CHECKING:
from homeassistant.core import HomeAssistant
def link_sub_integrations(hass: HomeAssistant) -> bool:
"""Link Spook sub integrations."""
def link_sub_integrations(hass: HomeAssistant) -> set[str]:
"""Link Spook sub integrations, and return the ones newly linked."""
LOGGER.debug("Linking up Spook sub integrations")
changes = False
linked: set[str] = set()
for manifest in Path(__file__).parent.rglob("integrations/*/manifest.json"):
LOGGER.debug("Linking Spook sub integration: %s", manifest.parent.name)
dest = Path(hass.config.config_dir) / "custom_components" / manifest.parent.name
@@ -28,8 +28,8 @@ def link_sub_integrations(hass: HomeAssistant) -> bool:
/ manifest.parent.name
)
dest.symlink_to(src)
changes = True
return changes
linked.add(manifest.parent.name)
return linked
def unlink_sub_integrations(hass: HomeAssistant) -> None:
@@ -40,3 +40,19 @@ def unlink_sub_integrations(hass: HomeAssistant) -> None:
dest = Path(hass.config.config_dir) / "custom_components" / manifest.parent.name
if dest.exists():
dest.unlink()
def sub_integration_links(hass: HomeAssistant) -> dict[str, bool]:
"""Return each Spook sub integration, and whether it is linked.
Linked means a symlink that leads to Spook's own copy. A folder or a
link to somewhere else with the same name loads other code, or none.
"""
custom_components = Path(hass.config.config_dir) / "custom_components"
links: dict[str, bool] = {}
for manifest in sorted(Path(__file__).parent.rglob("integrations/*/manifest.json")):
link = custom_components / manifest.parent.name
links[manifest.parent.name] = (
link.is_symlink() and link.resolve() == manifest.parent.resolve()
)
return links