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

Function extractDjangoModelsAST

src/ast/extract-python.ts:644–664  ·  view source on GitHub ↗
(
  filePath: string,
  content: string
)

Source from the content-addressed store, hash-verified

642 type: f.type || "unknown",
643 flags: f.flags || [],
644 })) as SchemaField[],
645 relations: (m.relations || []).map((r: any) => `${r.name}: ${r.target}`),
646 orm: "sqlalchemy" as const,
647 confidence: "ast" as const,
648 }));
649}
650
651/**
652 * Extract Django ORM models from a Python file using AST.
653 * Handles models.Model subclasses with CharField, ForeignKey, etc.
654 */
655export async function extractDjangoModelsAST(
656 filePath: string,
657 content: string
658): Promise<SchemaModel[] | null> {
659 const result = await runPythonWithStdin(PYTHON_DJANGO_SCRIPT, content, filePath);
660 if (!result || !Array.isArray(result) || result.length === 0) return null;
661
662 return result.map((m: any) => ({
663 name: m.name,
664 fields: (m.fields || []).map((f: any) => ({
665 name: f.name,
666 type: f.type || "unknown",
667 flags: f.flags || [],

Callers 1

detectDjangoSchemasFunction · 0.85

Calls 1

runPythonWithStdinFunction · 0.85

Tested by

no test coverage detected