MCPcopy Create free account
hub / github.com/Houseofmvps/codesight / extractPythonRoutesAST

Function extractPythonRoutesAST

src/ast/extract-python.ts:596–614  ·  view source on GitHub ↗
(
  filePath: string,
  content: string,
  framework: Framework,
  tags: string[]
)

Source from the content-addressed store, hash-verified

594 });
595}
596
597/**
598 * Extract routes from a Python file using AST.
599 * Returns routes with confidence: "ast", or null if Python is unavailable.
600 */
601export async function extractPythonRoutesAST(
602 filePath: string,
603 content: string,
604 framework: Framework,
605 tags: string[]
606): Promise<RouteInfo[] | null> {
607 const result = await runPythonWithStdin(PYTHON_ROUTE_SCRIPT, content, filePath);
608 if (!result || !Array.isArray(result) || result.length === 0) return null;
609
610 // Tag from the handler's own line span when the AST reports one (issue #52);
611 // routes without span info (urlpatterns entries) keep the caller's tags.
612 const lines = content.split("\n");
613 return result.map((r: any) => ({
614 method: r.method,
615 path: r.path,
616 file: filePath,
617 tags:

Callers 3

detectFastAPIRoutesFunction · 0.85
detectFlaskRoutesFunction · 0.85
detectDjangoRoutesFunction · 0.85

Calls 2

runPythonWithStdinFunction · 0.85
extractPathParamsFunction · 0.70

Tested by

no test coverage detected