Make hassfest service validation faster (#50003)

This commit is contained in:
Paulus Schoutsen 2021-05-02 21:49:51 -07:00 committed by GitHub
parent 8ca6b8394c
commit 8e0e1405e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,6 +65,9 @@ def grep_dir(path: pathlib.Path, glob_pattern: str, search_pattern: str) -> bool
def validate_services(integration: Integration): def validate_services(integration: Integration):
"""Validate services.""" """Validate services."""
try:
data = load_yaml(str(integration.path / "services.yaml"))
except FileNotFoundError:
# Find if integration uses services # Find if integration uses services
has_services = grep_dir( has_services = grep_dir(
integration.path, integration.path,
@ -72,18 +75,13 @@ def validate_services(integration: Integration):
r"(hass\.services\.(register|async_register))|async_register_entity_service|async_register_admin_service", r"(hass\.services\.(register|async_register))|async_register_entity_service|async_register_admin_service",
) )
if not has_services: if has_services:
return integration.add_error(
"services", "Registers services but has no services.yaml"
try: )
data = load_yaml(str(integration.path / "services.yaml"))
except FileNotFoundError:
integration.add_error("services", "Registers services but has no services.yaml")
return return
except HomeAssistantError: except HomeAssistantError:
integration.add_error( integration.add_error("services", "Unable to load services.yaml")
"services", "Registers services but unable to load services.yaml"
)
return return
try: try: