28 lines
697 B
Python
28 lines
697 B
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class Entrypoint:
|
|
entry_id: str
|
|
entry_type: str
|
|
framework: str
|
|
route_or_command: str
|
|
handler_symbol_id: str
|
|
path: str
|
|
start_line: int
|
|
end_line: int
|
|
metadata: dict = field(default_factory=dict)
|
|
|
|
|
|
class EntrypointDetectorRegistry:
|
|
def __init__(self, detectors: list) -> None:
|
|
self._detectors = detectors
|
|
|
|
def detect_all(self, *, path: str, symbols: list) -> list[Entrypoint]:
|
|
items: list[Entrypoint] = []
|
|
for detector in self._detectors:
|
|
items.extend(detector.detect(path=path, symbols=symbols))
|
|
return items
|