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:
parent
fc481133e7
commit
e8343452cd
19 changed files with 415 additions and 220 deletions
|
@ -3,11 +3,12 @@
|
|||
import fnmatch
|
||||
import importlib
|
||||
import os
|
||||
import pathlib
|
||||
import pkgutil
|
||||
import re
|
||||
import sys
|
||||
|
||||
from script.manifest.requirements import gather_requirements_from_manifests
|
||||
from script.hassfest.model import Integration
|
||||
|
||||
COMMENT_REQUIREMENTS = (
|
||||
'Adafruit-DHT',
|
||||
|
@ -219,7 +220,7 @@ def gather_modules():
|
|||
|
||||
errors = []
|
||||
|
||||
gather_requirements_from_manifests(process_requirements, errors, reqs)
|
||||
gather_requirements_from_manifests(errors, reqs)
|
||||
gather_requirements_from_modules(errors, reqs)
|
||||
|
||||
for key in reqs:
|
||||
|
@ -235,6 +236,28 @@ def gather_modules():
|
|||
return reqs
|
||||
|
||||
|
||||
def gather_requirements_from_manifests(errors, reqs):
|
||||
"""Gather all of the requirements from manifests."""
|
||||
integrations = Integration.load_dir(pathlib.Path(
|
||||
'homeassistant/components'
|
||||
))
|
||||
for domain in sorted(integrations):
|
||||
integration = integrations[domain]
|
||||
|
||||
if not integration.manifest:
|
||||
errors.append(
|
||||
'The manifest for component {} is invalid.'.format(domain)
|
||||
)
|
||||
continue
|
||||
|
||||
process_requirements(
|
||||
errors,
|
||||
integration.manifest['requirements'],
|
||||
'homeassistant.components.{}'.format(domain),
|
||||
reqs
|
||||
)
|
||||
|
||||
|
||||
def gather_requirements_from_modules(errors, reqs):
|
||||
"""Collect the requirements from the modules directly."""
|
||||
for package in sorted(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue