Make hassfest service validation faster (#50003)

pull/50029/head
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
1 changed files with 12 additions and 14 deletions

View File

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