mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Validate component usage (#23037)
* Update manifest validator * Update circle * Update text * Typo * fix link to codeowners * Merge CODEOWNERS into hassfest * Annotate errors with fixable * Convert error to warning * Lint * Make abs path * Python 3.5... * Typo * Fix tests
This commit is contained in:
40
script/hassfest/manifest.py
Normal file
40
script/hassfest/manifest.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""Manifest validation."""
|
||||
from typing import Dict
|
||||
|
||||
import voluptuous as vol
|
||||
from voluptuous.humanize import humanize_error
|
||||
|
||||
from .model import Integration
|
||||
|
||||
|
||||
MANIFEST_SCHEMA = vol.Schema({
|
||||
vol.Required('domain'): str,
|
||||
vol.Required('name'): str,
|
||||
vol.Required('documentation'): str,
|
||||
vol.Required('requirements'): [str],
|
||||
vol.Required('dependencies'): [str],
|
||||
vol.Required('codeowners'): [str],
|
||||
})
|
||||
|
||||
|
||||
def validate_manifest(integration: Integration):
|
||||
"""Validate manifest."""
|
||||
try:
|
||||
MANIFEST_SCHEMA(integration.manifest)
|
||||
except vol.Invalid as err:
|
||||
integration.add_error(
|
||||
'manifest',
|
||||
"Invalid manifest: {}".format(
|
||||
humanize_error(integration.manifest, err)))
|
||||
integration.manifest = None
|
||||
return
|
||||
|
||||
if integration.manifest['domain'] != integration.path.name:
|
||||
integration.add_error('manifest', 'Domain does not match dir name')
|
||||
|
||||
|
||||
def validate(integrations: Dict[str, Integration], config):
|
||||
"""Handle all integrations manifests."""
|
||||
for integration in integrations.values():
|
||||
if integration.manifest:
|
||||
validate_manifest(integration)
|
||||
Reference in New Issue
Block a user