mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-18 17:54:04 +02:00
build: extract strings sync script for local use
This commit is contained in:
parent
f95093e1dc
commit
11bd4d214e
7 changed files with 19 additions and 12 deletions
27
scripts/update-services.py
Normal file
27
scripts/update-services.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"""Creates a services.yaml file with the latest docs."""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
sys.path.append(str(Path(__file__).parent.parent))
|
||||
|
||||
from custom_components.adaptive_lighting import const
|
||||
|
||||
services_filename = Path("custom_components") / "adaptive_lighting" / "services.yaml"
|
||||
with open(services_filename) as f: # noqa: PTH123
|
||||
services = yaml.safe_load(f)
|
||||
|
||||
for service_name, dct in services.items():
|
||||
_docs = {"set_manual_control": const.DOCS_MANUAL_CONTROL, "apply": const.DOCS_APPLY}
|
||||
alternative_docs = _docs.get(service_name, const.DOCS)
|
||||
for field_name, field in dct["fields"].items():
|
||||
description = alternative_docs.get(field_name, const.DOCS[field_name])
|
||||
field["description"] = description
|
||||
|
||||
comment = "# This file is auto-generated by .github/update-services.py."
|
||||
|
||||
with services_filename.open("w") as f:
|
||||
f.write(comment + "\n")
|
||||
yaml.dump(services, f, sort_keys=False, width=1000, allow_unicode=True)
|
||||
Loading…
Add table
Add a link
Reference in a new issue