mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Simplify loading of icons (#110687)
This commit is contained in:
parent
a0ead2b861
commit
53062a81cc
@ -104,10 +104,7 @@ class _IconsCache:
|
|||||||
|
|
||||||
async def _async_load(self, components: set[str]) -> None:
|
async def _async_load(self, components: set[str]) -> None:
|
||||||
"""Populate the cache for a given set of components."""
|
"""Populate the cache for a given set of components."""
|
||||||
_LOGGER.debug(
|
_LOGGER.debug("Cache miss for: %s", components)
|
||||||
"Cache miss for: %s",
|
|
||||||
", ".join(components),
|
|
||||||
)
|
|
||||||
|
|
||||||
integrations: dict[str, Integration] = {}
|
integrations: dict[str, Integration] = {}
|
||||||
domains = {loaded.rpartition(".")[-1] for loaded in components}
|
domains = {loaded.rpartition(".")[-1] for loaded in components}
|
||||||
@ -129,16 +126,15 @@ class _IconsCache:
|
|||||||
icons: dict[str, dict[str, Any]],
|
icons: dict[str, dict[str, Any]],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Extract resources into the cache."""
|
"""Extract resources into the cache."""
|
||||||
resource: dict[str, Any] | str
|
|
||||||
categories: set[str] = set()
|
categories: set[str] = set()
|
||||||
|
|
||||||
for resource in icons.values():
|
for resource in icons.values():
|
||||||
categories.update(resource)
|
categories.update(resource)
|
||||||
|
|
||||||
for category in categories:
|
for category in categories:
|
||||||
new_resources = build_resources(icons, components, category)
|
self._cache.setdefault(category, {}).update(
|
||||||
for component, resource in new_resources.items():
|
build_resources(icons, components, category)
|
||||||
category_cache: dict[str, Any] = self._cache.setdefault(category, {})
|
)
|
||||||
category_cache[component] = resource
|
|
||||||
|
|
||||||
|
|
||||||
async def async_get_icons(
|
async def async_get_icons(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user