Require an icon for a service (#112373)
parent
ed9b5d843c
commit
85e13bdb87
|
@ -139,6 +139,13 @@ def validate_services(config: Config, integration: Integration) -> None:
|
||||||
)
|
)
|
||||||
return
|
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
|
# Try loading translation strings
|
||||||
if integration.core:
|
if integration.core:
|
||||||
strings_file = integration.path / "strings.json"
|
strings_file = integration.path / "strings.json"
|
||||||
|
@ -155,9 +162,17 @@ def validate_services(config: Config, integration: Integration) -> None:
|
||||||
if not integration.core:
|
if not integration.core:
|
||||||
error_msg_suffix = f"and is not {error_msg_suffix}"
|
error_msg_suffix = f"and is not {error_msg_suffix}"
|
||||||
|
|
||||||
# For each service in the integration, check if the description if set,
|
# For each service in the integration:
|
||||||
# if not, check if it's in the strings file. If not, add an error.
|
# 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():
|
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:
|
if service_schema is None:
|
||||||
continue
|
continue
|
||||||
if "name" not in service_schema:
|
if "name" not in service_schema:
|
||||||
|
|
Loading…
Reference in New Issue