refactor: auto-derive pattern cap keys from href; move dumps to tests/fixtures
Remove key_fn from Capability — pattern cap keys are now always derived automatically: strip digits from href segments, join with '_', append '_' + desc.key. /door/cooler/0 + 'open' -> door_cooler_open. DOOR_GENERIC entity key: 'open' (not 'door_open'). Remove _door_key helper. Fridge registry: DOOR_FRIDGE/DOOR_FREEZER replaced by DOOR_GENERIC pattern cap. Golden baseline: door_fridge_open -> door_cooler_open. Move device dumps to tests/fixtures/dumps/ (tracked) so tests run in CI without local-tools/ dependencies.
This commit is contained in:
1 parent
1c4cb2e272
commit
27d6d09fd9
11 files changed
+37
-51
No files matched your search
@@ -68,10 +68,12 @@ def discover(
|
||||
if cap.match_fn is not None and not cap.match_fn(rep, resources):
|
||||
continue
|
||||
inst = instance_suffix(href)
|
||||
key = cap.key_fn(href) if cap.key_fn else None
|
||||
# Auto-derive key prefix from href: strip digits, join non-empty segs with '_'
|
||||
segs = [s for s in href.strip('/').split('/') if s and not s.isdigit()]
|
||||
for desc in cap.entities:
|
||||
key_override = '_'.join(segs) + '_' + desc.key
|
||||
out.append(BoundEntity(href=href, capability=cap, desc=desc,
|
||||
instance=inst, key_override=key))
|
||||
instance=inst, key_override=key_override))
|
||||
matched = True
|
||||
break
|
||||
|
||||
|
||||
Reference in new issue
Block a user