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:
Paulus Schoutsen 2019-04-13 13:17:01 -07:00 committed by GitHub
parent fc481133e7
commit e8343452cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 415 additions and 220 deletions

View file

@ -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(