MCPcopy Create free account
hub / github.com/SethGammon/Citadel / extractPython

Function extractPython

core/map/index.js:186–212  ·  view source on GitHub ↗
(content)

Source from the content-addressed store, hash-verified

184}
185
186function extractPython(content) {
187 const exports = [];
188 const imports = [];
189 const symbols = [];
190 let m;
191
192 const allRe = /__all__\s*=\s*\[([^\]]*)\]/g;
193 while ((m = allRe.exec(content)) !== null) {
194 const names = m[1].match(/['"](\w+)['"]/g) || [];
195 for (const quoted of names) {
196 const clean = quoted.replace(/['"]/g, '');
197 exports.push(clean);
198 symbols.push(clean);
199 }
200 }
201
202 const defRe = /^(?:def|class)\s+(\w+)/gm;
203 while ((m = defRe.exec(content)) !== null) {
204 symbols.push(m[1]);
205 if (exports.length === 0 && !m[1].startsWith('_')) exports.push(m[1]);
206 }
207
208 const importRe = /^(?:from\s+([\w.]+)\s+import|import\s+([\w.]+))/gm;
209 while ((m = importRe.exec(content)) !== null) imports.push(m[1] || m[2]);
210
211 return { exports: dedupe(exports), imports: dedupe(imports), symbols: dedupe(symbols) };
212}
213
214function extractGo(content) {
215 const exports = [];

Callers 1

extractFileFunction · 0.85

Calls 1

dedupeFunction · 0.85

Tested by

no test coverage detected