mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 12:45:28 +02:00
Black
This commit is contained in:
@@ -3,35 +3,19 @@ import pathlib
|
||||
import sys
|
||||
|
||||
from .model import Integration, Config
|
||||
from . import (
|
||||
codeowners,
|
||||
config_flow,
|
||||
dependencies,
|
||||
manifest,
|
||||
services,
|
||||
ssdp,
|
||||
zeroconf,
|
||||
)
|
||||
from . import codeowners, config_flow, dependencies, manifest, services, ssdp, zeroconf
|
||||
|
||||
PLUGINS = [
|
||||
codeowners,
|
||||
config_flow,
|
||||
dependencies,
|
||||
manifest,
|
||||
services,
|
||||
ssdp,
|
||||
zeroconf,
|
||||
]
|
||||
PLUGINS = [codeowners, config_flow, dependencies, manifest, services, ssdp, zeroconf]
|
||||
|
||||
|
||||
def get_config() -> Config:
|
||||
"""Return config."""
|
||||
if not pathlib.Path('requirements_all.txt').is_file():
|
||||
if not pathlib.Path("requirements_all.txt").is_file():
|
||||
raise RuntimeError("Run from project root")
|
||||
|
||||
return Config(
|
||||
root=pathlib.Path('.').absolute(),
|
||||
action='validate' if sys.argv[-1] == 'validate' else 'generate',
|
||||
root=pathlib.Path(".").absolute(),
|
||||
action="validate" if sys.argv[-1] == "validate" else "generate",
|
||||
)
|
||||
|
||||
|
||||
@@ -43,22 +27,19 @@ def main():
|
||||
print(err)
|
||||
return 1
|
||||
|
||||
integrations = Integration.load_dir(
|
||||
pathlib.Path('homeassistant/components')
|
||||
)
|
||||
integrations = Integration.load_dir(pathlib.Path("homeassistant/components"))
|
||||
|
||||
for plugin in PLUGINS:
|
||||
plugin.validate(integrations, config)
|
||||
|
||||
# When we generate, all errors that are fixable will be ignored,
|
||||
# as generating them will be fixed.
|
||||
if config.action == 'generate':
|
||||
if config.action == "generate":
|
||||
general_errors = [err for err in config.errors if not err.fixable]
|
||||
invalid_itg = [
|
||||
itg for itg in integrations.values()
|
||||
if any(
|
||||
not error.fixable for error in itg.errors
|
||||
)
|
||||
itg
|
||||
for itg in integrations.values()
|
||||
if any(not error.fixable for error in itg.errors)
|
||||
]
|
||||
else:
|
||||
# action == validate
|
||||
@@ -70,13 +51,13 @@ def main():
|
||||
|
||||
if not invalid_itg and not general_errors:
|
||||
for plugin in PLUGINS:
|
||||
if hasattr(plugin, 'generate'):
|
||||
if hasattr(plugin, "generate"):
|
||||
plugin.generate(integrations, config)
|
||||
|
||||
return 0
|
||||
|
||||
print()
|
||||
if config.action == 'generate':
|
||||
if config.action == "generate":
|
||||
print("Found errors. Generating files canceled.")
|
||||
print()
|
||||
|
||||
|
Reference in New Issue
Block a user