Update HACS
This commit is contained in:
@@ -14,10 +14,9 @@ class ValidationException(HacsException):
|
||||
"""Raise when there is a validation issue."""
|
||||
|
||||
|
||||
class ValidationBase:
|
||||
"""Base class for validation."""
|
||||
class ActionValidationBase:
|
||||
"""Base class for action validation."""
|
||||
|
||||
action_only: bool = False
|
||||
category: str = "common"
|
||||
|
||||
def __init__(self, repository: HacsRepository) -> None:
|
||||
@@ -30,29 +29,23 @@ class ValidationBase:
|
||||
"""Return the check slug."""
|
||||
return self.__class__.__module__.rsplit(".", maxsplit=1)[-1]
|
||||
|
||||
async def async_validate(self) -> None:
|
||||
"""Validate the repository."""
|
||||
|
||||
async def execute_validation(self, *_, **__) -> None:
|
||||
"""Execute the task defined in subclass."""
|
||||
self.hacs.log.debug("Validation<%s> Starting validation", self.slug)
|
||||
self.hacs.log.info("<Validation %s> Starting validation", self.slug)
|
||||
|
||||
start_time = monotonic()
|
||||
self.failed = False
|
||||
|
||||
try:
|
||||
if task := getattr(self, "validate", None):
|
||||
await self.hacs.hass.async_add_executor_job(task)
|
||||
elif task := getattr(self, "async_validate", None):
|
||||
await task() # pylint: disable=not-callable
|
||||
await self.async_validate()
|
||||
except ValidationException as exception:
|
||||
self.failed = True
|
||||
self.hacs.log.error("Validation<%s> failed: %s", self.slug, exception)
|
||||
self.hacs.log.error("<Validation %s> failed: %s", self.slug, exception)
|
||||
|
||||
else:
|
||||
self.hacs.log.debug(
|
||||
"Validation<%s> took %.3f seconds to complete", self.slug, monotonic() - start_time
|
||||
"<Validation %s> took %.3f seconds to complete", self.slug, monotonic() - start_time
|
||||
)
|
||||
|
||||
|
||||
class ActionValidationBase(ValidationBase):
|
||||
"""Base class for action validation."""
|
||||
|
||||
action_only = True
|
||||
|
||||
Reference in New Issue
Block a user