Simplify loading of icons (#110687)

pull/110898/head
J. Nick Koston 2024-02-16 09:51:14 -06:00 committed by GitHub
parent a0ead2b861
commit 53062a81cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 9 deletions

View File

@ -104,10 +104,7 @@ class _IconsCache:
async def _async_load(self, components: set[str]) -> None:
"""Populate the cache for a given set of components."""
_LOGGER.debug(
"Cache miss for: %s",
", ".join(components),
)
_LOGGER.debug("Cache miss for: %s", components)
integrations: dict[str, Integration] = {}
domains = {loaded.rpartition(".")[-1] for loaded in components}
@ -129,16 +126,15 @@ class _IconsCache:
icons: dict[str, dict[str, Any]],
) -> None:
"""Extract resources into the cache."""
resource: dict[str, Any] | str
categories: set[str] = set()
for resource in icons.values():
categories.update(resource)
for category in categories:
new_resources = build_resources(icons, components, category)
for component, resource in new_resources.items():
category_cache: dict[str, Any] = self._cache.setdefault(category, {})
category_cache[component] = resource
self._cache.setdefault(category, {}).update(
build_resources(icons, components, category)
)
async def async_get_icons(