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

Function parsePyprojectProjectDeps

src/scanner.ts:1174–1200  ·  view source on GitHub ↗

PEP 621: [project] dependencies = [...]

(toml: string, deps: string[])

Source from the content-addressed store, hash-verified

1172
1173/** PEP 621: [project] dependencies = [...] */
1174function parsePyprojectProjectDeps(toml: string, deps: string[]): void {
1175 const projectIdx = toml.indexOf("[project]");
1176 if (projectIdx < 0) return;
1177
1178 const afterProject = toml.slice(projectIdx);
1179 const depMatch = afterProject.match(/\bdependencies\s*=\s*\[/);
1180 if (!depMatch) return;
1181
1182 // Bracket counting to handle packages with extras like django[bcrypt]
1183 const arrStart = projectIdx + (depMatch.index ?? 0) + depMatch[0].length - 1;
1184 let depth = 1;
1185 let pos = arrStart + 1;
1186 let inStr = false;
1187 while (pos < toml.length && depth > 0) {
1188 const ch = toml[pos];
1189 if (ch === '"' && toml[pos - 1] !== "\\") inStr = !inStr;
1190 if (!inStr) {
1191 if (ch === "[") depth++;
1192 else if (ch === "]") depth--;
1193 }
1194 pos++;
1195 }
1196 const depsContent = toml.slice(arrStart + 1, pos - 1);
1197 for (const m of depsContent.matchAll(/"([^"]+)"/g)) {
1198 addPythonDep(m[1].split(/[>=<\[!~;]/)[0], deps);
1199 }
1200}
1201
1202/** Poetry: [tool.poetry.dependencies] — key = "version" pairs */
1203function parsePyprojectPoetryDeps(toml: string, deps: string[]): void {

Callers 1

getPythonDepsFunction · 0.85

Calls 1

addPythonDepFunction · 0.85

Tested by

no test coverage detected