adaptive-lighting/test_dependencies.py
Bas Nijholt bb84684bce
Style with ruff and logging (#643)
* Formatting with ruff

* more logging

* Require on_only

* Different implementation

* More ruff

* Remove new logging statements

* Remove 'pylint: disable=protected'

* style

* fixes

* ruff

* Switch to ruff

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix .github

* Fix

* Add ignores

* fix arg

* fix B905

* Fix D

* Fix more

* Fix more

* order

* use path

* moer path

* Remove unused ignores

* fix tes deps

* fix typo

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-07-23 14:24:22 -07:00

41 lines
1.2 KiB
Python

"""Extracts the dependencies of the components required for testing."""
from collections import defaultdict
from pathlib import Path
deps = defaultdict(list)
components, packages = [], []
requirements = Path("core") / "requirements_test_all.txt"
with requirements.open() as f:
lines = f.readlines()
for line in lines:
line = line.strip() # noqa: PLW2901
if line.startswith("# homeassistant."):
if components and packages:
for component in components:
deps[component].extend(packages)
components, packages = [], []
components.append(line.split("# homeassistant.")[1])
elif components and line:
packages.append(line)
# The last batch of components and packages
if components and packages:
for component in components:
deps[component].extend(packages)
required = [
"components.recorder",
"components.mqtt",
"components.zeroconf",
"components.http",
"components.stream",
"components.conversation", # only available after HA≥2023.2
"components.cloud",
]
to_install = [package for r in required for package in deps[r]]
print(" ".join(to_install)) # noqa: T201