29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
from __future__ import annotations
|
|
|
|
from hashlib import sha256
|
|
|
|
from app.modules.rag.indexing.code.entrypoints.registry import Entrypoint
|
|
|
|
|
|
class FlaskEntrypointDetector:
|
|
def detect(self, *, path: str, symbols: list) -> list[Entrypoint]:
|
|
items: list[Entrypoint] = []
|
|
for symbol in symbols:
|
|
for decorator in symbol.decorators or []:
|
|
lowered = decorator.lower()
|
|
if ".route" not in lowered:
|
|
continue
|
|
items.append(
|
|
Entrypoint(
|
|
entry_id=sha256(f"{path}|flask|{symbol.symbol_id}|{decorator}".encode("utf-8")).hexdigest(),
|
|
entry_type="http",
|
|
framework="flask",
|
|
route_or_command=decorator,
|
|
handler_symbol_id=symbol.symbol_id,
|
|
path=path,
|
|
start_line=symbol.start_line,
|
|
end_line=symbol.end_line,
|
|
)
|
|
)
|
|
return items
|