mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-27 12:24:19 +02:00
Refactor, simplify code, rename, and set minimal HA core ≥2022.11 (#655)
* Rename TurnOnOffListener to AdaptiveLightingManager * Bump Python version * Refactor and unify methods that are called once * Simplify adaptation_utils.py * Improve readability in adaptation_utils.py * More renames * Simplify * More renames and simplifications * fix test * simplify _supported_features * rename * walrus * drop old astral support * Only support HA ≥2021.06 * Require 2016.06 * Try 2023.1 * even more old versions * test * more versions * verify that only ≥2022.11 works * named args * setdefault * no astral v1 * var * simplify * no need to pass adapt_brightness and adapt_color * Add comment
This commit is contained in:
parent
69592938db
commit
c1528ec10a
7 changed files with 166 additions and 208 deletions
|
|
@ -1,22 +1,27 @@
|
|||
from collections import defaultdict
|
||||
|
||||
deps = defaultdict(list)
|
||||
components, packages = [], []
|
||||
|
||||
with open("core/requirements_test_all.txt") as f:
|
||||
lines = f.readlines()
|
||||
|
||||
components = []
|
||||
packages = []
|
||||
deps = {}
|
||||
for i, line in enumerate(lines):
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
|
||||
if line.startswith("# homeassistant."):
|
||||
component = line.split("# homeassistant.")[1]
|
||||
components.append(component)
|
||||
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)
|
||||
else:
|
||||
for component in components:
|
||||
for package in packages:
|
||||
deps.setdefault(component, []).append(package)
|
||||
components = []
|
||||
packages = []
|
||||
|
||||
# The last batch of components and packages
|
||||
if components and packages:
|
||||
for component in components:
|
||||
deps[component].extend(packages)
|
||||
|
||||
required = [
|
||||
"components.recorder",
|
||||
|
|
@ -24,10 +29,9 @@ required = [
|
|||
"components.zeroconf",
|
||||
"components.http",
|
||||
"components.stream",
|
||||
"components.conversation",
|
||||
"components.conversation", # only available after HA≥2023.2
|
||||
"components.cloud",
|
||||
]
|
||||
to_install = []
|
||||
for r in required:
|
||||
to_install.extend(deps[r])
|
||||
to_install = [package for r in required for package in deps[r]]
|
||||
|
||||
print(" ".join(to_install))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue