Skip to content

Commit b7d39c8

Browse files
committed
Update HandlerRegistry references to Actions and update test directory for event_handlers
1 parent 733f799 commit b7d39c8

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

streamdeck/event_handlers/registry.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@
1313

1414

1515
class HandlersRegistry:
16-
"""Manages the registration and retrieval of actions and their event handlers."""
17-
_plugin_actions: list[SupportsEventHandlers]
18-
"""List of registered actions."""
16+
"""Manages the registration and retrieval of event handler catalogs and their event handlers."""
17+
_plugin_event_handler_catalogs: list[SupportsEventHandlers]
18+
"""List of registered actions and other event handler catalogs."""
1919

2020
def __init__(self) -> None:
21-
"""Initialize an HandlersRegistry instance."""
22-
self._plugin_actions = []
21+
"""Initialize a HandlersRegistry instance."""
22+
self._plugin_event_handler_catalogs = []
2323

24-
def register(self, action: SupportsEventHandlers) -> None:
25-
"""Register an action with the registry.
24+
def register(self, catalog: SupportsEventHandlers) -> None:
25+
"""Register an event handler catalog with the registry.
2626
2727
Args:
28-
action (Action): The action to register.
28+
catalog (SupportsEventHandlers): The event handler catalog to register.
2929
"""
30-
self._plugin_actions.append(action)
30+
self._plugin_event_handler_catalogs.append(catalog)
3131

3232
def get_event_handlers(self, event_name: EventNameStr, event_action_uuid: ActionUUIDStr | None = None) -> Generator[EventHandlerFunc, None, None]:
33-
"""Get all event handlers for a specific event from all registered actions.
33+
"""Get all event handlers for a specific event from all registered event handler catalogs.
3434
3535
Args:
3636
event_name (EventName): The name of the event to retrieve handlers for.
@@ -40,11 +40,11 @@ def get_event_handlers(self, event_name: EventNameStr, event_action_uuid: Action
4040
Yields:
4141
EventHandlerFunc: The event handler functions for the specified event.
4242
"""
43-
for action in self._plugin_actions:
43+
for catalog in self._plugin_event_handler_catalogs:
4444
# If the event is action-specific (i.e is not a GlobalAction and has a UUID attribute),
4545
# only get handlers for that action, as we don't want to trigger
4646
# and pass this event to handlers for other actions.
47-
if event_action_uuid is not None and (isinstance(action, Action) and action.uuid != event_action_uuid):
47+
if event_action_uuid is not None and (isinstance(catalog, Action) and catalog.uuid != event_action_uuid):
4848
continue
4949

50-
yield from action.get_event_handlers(event_name)
50+
yield from catalog.get_event_handlers(event_name)

tests/actions/test_action_event_handler_filtering.py renamed to tests/event_handlers/test_action_event_handler_filtering.py

File renamed without changes.

tests/actions/test_action_registry.py renamed to tests/event_handlers/test_action_registry.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ def test_register_action() -> None:
2222
registry = HandlersRegistry()
2323
action = Action("my-fake-action-uuid")
2424

25-
assert len(registry._plugin_actions) == 0
25+
assert len(registry._plugin_event_handler_catalogs) == 0
2626

2727
registry.register(action)
28-
assert len(registry._plugin_actions) == 1
29-
assert registry._plugin_actions[0] == action
28+
assert len(registry._plugin_event_handler_catalogs) == 1
29+
assert registry._plugin_event_handler_catalogs[0] == action
3030

3131

3232
def test_get_event_handlers_no_handlers() -> None:

0 commit comments

Comments
 (0)