Build every screen from one shared core plus a small file per board, the same firmware as before (0.2.84)
The two board profiles (5,000 lines each, 87 % the same text) become packages/core.yaml and one file per board under packages/boards/: the hardware, a table of 84 sizes and font sizes, 18 hooks with the lines of C++ only that board adds inside a shared lambda, and the board's own sections. packages/cyd.yaml and packages/guition.yaml keep their names and places (a screen installed from ESP Screens builds as before); home-like-2432s028.yaml and guition-4848s040.yaml become the same entries for a checkout. The firmware stays 0.2.70: the C++ ESPHome generates for each board, through the checkout profile and through the GitHub package route, was compared line by line with the old profiles' (docs/TEST_RESULTS_0284.md). tools/check_packages.py replaces tools/generate_packages.py; tools/profiles.py gives the tests and tools the three files as one; docs/PROFILES.md says how the files fit together and how a board is added. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,8 @@ import unittest
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / 'tools'))
|
||||
import profiles # noqa: E402
|
||||
sys.path.insert(0, str(ROOT / 'screen_manager/app'))
|
||||
from core import FIRMWARE_VERSION, WAKE_SLEEP_MIN_FIRMWARE # noqa: E402
|
||||
|
||||
@@ -20,13 +22,19 @@ PROFILES = ('home-like-2432s028.yaml', 'guition-4848s040.yaml', 'packages/cyd.ya
|
||||
|
||||
def section(text, top):
|
||||
"""One top-level YAML section of a profile, up to the next one."""
|
||||
match = re.search(rf'^{top}:\n(.*?)(?=^[a-z_]+:|\Z)', text, re.M | re.S)
|
||||
return match[1] if match else ''
|
||||
# The core and the board file may both carry the section (app 0.2.84+).
|
||||
return '\n'.join(re.findall(rf'^{top}:\n(.*?)(?=^[a-z_]+:|\Z)', text, re.M | re.S))
|
||||
|
||||
|
||||
def item(text, key, value):
|
||||
"""The list item in a section that carries `key: value`, up to the next item at the same depth."""
|
||||
for chunk in re.split(r'^ - ', text, flags=re.M)[1:]:
|
||||
chunks = re.split(r'^ - ', text, flags=re.M)[1:]
|
||||
# The item that starts with `key: value` first: a script that names another one (`id: alert_dismiss` in
|
||||
# alert_timeout) may come before that one's own block now that the board file adds scripts of its own.
|
||||
for chunk in chunks:
|
||||
if re.match(rf'{key}: "?{re.escape(value)}"?$', chunk, re.M):
|
||||
return chunk
|
||||
for chunk in chunks:
|
||||
if re.search(rf'^\s*{key}: "?{re.escape(value)}"?$', chunk, re.M):
|
||||
return chunk
|
||||
return ''
|
||||
@@ -38,7 +46,7 @@ def script(text, name):
|
||||
|
||||
class Profiles(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.profiles = {name: (ROOT / name).read_text() for name in PROFILES}
|
||||
self.profiles = {name: profiles.text(name) for name in PROFILES}
|
||||
|
||||
def test_the_firmware_that_carries_the_buttons_is_this_release_or_older(self):
|
||||
version = lambda text: tuple(int(part) for part in text.split('.'))
|
||||
|
||||
Reference in New Issue
Block a user