mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Make hassfest service validation faster (#50003)
This commit is contained in:
parent
8ca6b8394c
commit
8e0e1405e8
@ -65,25 +65,23 @@ 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."""
|
||||||
# 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:
|
try:
|
||||||
data = load_yaml(str(integration.path / "services.yaml"))
|
data = load_yaml(str(integration.path / "services.yaml"))
|
||||||
except FileNotFoundError:
|
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
|
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:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user