MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_all_modules

Function get_all_modules

scripts/update_lib/cmd_deps.py:19–56  ·  view source on GitHub ↗

Get all top-level module names from cpython/Lib/. Includes private modules (_*) that are not hard_deps of other modules. Returns: Sorted list of module names (without .py extension)

(cpython_prefix: str)

Source from the content-addressed store, hash-verified

17
18
19def get_all_modules(cpython_prefix: str) -> list[str]:
20 """Get all top-level module names from cpython/Lib/.
21
22 Includes private modules (_*) that are not hard_deps of other modules.
23
24 Returns:
25 Sorted list of module names (without .py extension)
26 """
27 from update_lib.deps import resolve_hard_dep_parent
28
29 lib_dir = pathlib.Path(cpython_prefix) / "Lib"
30 if not lib_dir.exists():
31 return []
32
33 modules = set()
34 for entry in lib_dir.iterdir():
35 # Skip hidden files
36 if entry.name.startswith("."):
37 continue
38 # Skip test directory
39 if entry.name == "test":
40 continue
41
42 if entry.is_file() and entry.suffix == ".py":
43 name = entry.stem
44 elif entry.is_dir() and (entry / "__init__.py").exists():
45 name = entry.name
46 else:
47 continue
48
49 # Skip modules that are hard_deps of other modules
50 # e.g., _pydatetime is a hard_dep of datetime, pydoc_data is a hard_dep of pydoc
51 if resolve_hard_dep_parent(name, cpython_prefix) is not None:
52 continue
53
54 modules.add(name)
55
56 return sorted(modules)
57
58
59def format_deps_tree(

Callers 4

compute_todo_listFunction · 0.90
get_untracked_filesFunction · 0.90
format_all_todoFunction · 0.90
show_depsFunction · 0.85

Calls 9

resolve_hard_dep_parentFunction · 0.90
setFunction · 0.85
sortedFunction · 0.85
existsMethod · 0.45
iterdirMethod · 0.45
startswithMethod · 0.45
is_fileMethod · 0.45
is_dirMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected