MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / parse_pyproject_toml

Function parse_pyproject_toml

src/pipeline/pass_pkgmap.c:413–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

411}
412
413static void parse_pyproject_toml(const char *source, int source_len, const char *rel_path,
414 cbm_pkg_entries_t *entries) {
415 const char *section = find_line_value(source, source_len, "[project]");
416 if (!section) {
417 return;
418 }
419 char *name = toml_extract_name(section, source + source_len);
420 if (!name) {
421 return;
422 }
423 py_normalize_name(name);
424
425 /* Register src/<name>/__init__ as primary entry */
426 char suffix[PKGMAP_PATH_BUF];
427 snprintf(suffix, sizeof(suffix), "src/%s/__init__", name);
428 char *entry = build_entry_path(rel_path, suffix);
429 char *name_copy = strdup(name);
430 pkg_entries_push(entries, name, entry);
431
432 /* Also register <name>/__init__ as alternative (no src/ prefix) */
433 char *alt_entry = NULL;
434 if (name_copy) {
435 snprintf(suffix, sizeof(suffix), "%s/__init__", name_copy);
436 alt_entry = build_entry_path(rel_path, suffix);
437 }
438
439 if (name_copy && alt_entry) {
440 pkg_entries_push(entries, name_copy, alt_entry);
441 } else {
442 free(name_copy);
443 free(alt_entry);
444 }
445}
446
447/* Extract PSR-4 entries from one composer.json autoload section ("autoload"
448 * or "autoload-dev": composer registers both, so test namespaces such as

Callers 1

cbm_pkgmap_try_parseFunction · 0.85

Calls 5

find_line_valueFunction · 0.85
toml_extract_nameFunction · 0.85
py_normalize_nameFunction · 0.85
build_entry_pathFunction · 0.85
pkg_entries_pushFunction · 0.85

Tested by

no test coverage detected