Keep the last in-template copy on main so history can restore it; product continues in jiangchang-ui-recorder. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
615 B
Python
32 lines
615 B
Python
"""Adapter registry."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Optional
|
|
|
|
_REGISTRY: list[Any] = []
|
|
|
|
|
|
def register_adapter(adapter: Any) -> Any:
|
|
_REGISTRY.append(adapter)
|
|
return adapter
|
|
|
|
|
|
def get_adapter(
|
|
*,
|
|
class_name: str = "",
|
|
title: str = "",
|
|
process_name: str = "",
|
|
) -> Optional[Any]:
|
|
for ad in _REGISTRY:
|
|
try:
|
|
if ad.matches(class_name=class_name, title=title, process_name=process_name):
|
|
return ad
|
|
except Exception:
|
|
continue
|
|
return None
|
|
|
|
|
|
def all_adapters() -> list[Any]:
|
|
return list(_REGISTRY)
|