MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / pick

Function pick

web/scripts/gen-catalog.mjs:148–156  ·  view source on GitHub ↗
(names)

Source from the content-addressed store, hash-verified

146 .filter((d) => d.isFile() && d.name.toLowerCase().endsWith(".py"))
147 .map((d) => d.name);
148 const pick = (names) => {
149 const byMain = names.find((n) => n.toLowerCase() === "main.py");
150 if (byMain) return byMain;
151 const slug = slugify(folder);
152 const byName = names.find(
153 (n) => slugify(n.replace(/\.py$/i, "")) === slug,
154 );
155 return byName || names[0];
156 };
157 if (pys.length) return path.join(dir, pick(pys));
158 // look one level deep for projects that nest their code in a subfolder
159 for (const d of top) {

Callers 1

findMainPyFunction · 0.85

Calls 1

slugifyFunction · 0.85

Tested by

no test coverage detected