Require an icon for a service (#112373)

pull/113796/head
Joost Lekkerkerker 2024-03-19 08:29:29 +01:00 committed by GitHub
parent ed9b5d843c
commit 85e13bdb87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 2 deletions

View File

@ -139,6 +139,13 @@ def validate_services(config: Config, integration: Integration) -> None:
)
return
icons_file = integration.path / "icons.json"
icons = {}
if icons_file.is_file():
with contextlib.suppress(ValueError):
icons = json.loads(icons_file.read_text())
service_icons = icons.get("services", {})
# Try loading translation strings
if integration.core:
strings_file = integration.path / "strings.json"
@ -155,9 +162,17 @@ def validate_services(config: Config, integration: Integration) -> None:
if not integration.core:
error_msg_suffix = f"and is not {error_msg_suffix}"
# For each service in the integration, check if the description if set,
# if not, check if it's in the strings file. If not, add an error.
# For each service in the integration:
# 1. Check if the service description is set, if not,
# check if it's in the strings file else add an error.
# 2. Check if the service has an icon set in icons.json.
# raise an error if not.,
for service_name, service_schema in services.items():
if service_name not in service_icons:
integration.add_error(
"services",
f"Service {service_name} has no icon in icons.json.",
)
if service_schema is None:
continue
if "name" not in service_schema: