utp_service/backend/app/plugins/registry.py
2026-04-07 00:29:35 +03:00

22 lines
624 B
Python

from app.plugins.base import BaseAction
class ActionRegistry:
def __init__(self) -> None:
self._actions: dict[str, BaseAction] = {}
def register(self, action: BaseAction) -> None:
self._actions[action.name] = action
def get(self, name: str) -> BaseAction | None:
return self._actions.get(name)
def all(self) -> list[BaseAction]:
return list(self._actions.values())
def for_category(self, category: str) -> list[BaseAction]:
return [a for a in self._actions.values() if a.is_compatible(category)]
# Module-level singleton
action_registry = ActionRegistry()