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

Function get_all_imports

scripts/update_lib/deps.py:967–985  ·  view source on GitHub ↗

Get all imports from a library file. Args: name: Module name cpython_prefix: CPython directory prefix Returns: Frozenset of all imported module names

(name: str, cpython_prefix: str)

Source from the content-addressed store, hash-verified

965
966@functools.cache
967def get_all_imports(name: str, cpython_prefix: str) -> frozenset[str]:
968 """Get all imports from a library file.
969
970 Args:
971 name: Module name
972 cpython_prefix: CPython directory prefix
973
974 Returns:
975 Frozenset of all imported module names
976 """
977 all_imports = set()
978 for lib_path in get_lib_paths(name, cpython_prefix):
979 if lib_path.exists():
980 for _, content in read_python_files(lib_path):
981 all_imports.update(parse_lib_imports(content))
982
983 # Remove self
984 all_imports.discard(name)
985 return frozenset(all_imports)
986
987
988@functools.cache

Callers 2

get_soft_depsFunction · 0.85
get_rust_depsFunction · 0.85

Calls 7

read_python_filesFunction · 0.90
setFunction · 0.85
get_lib_pathsFunction · 0.85
parse_lib_importsFunction · 0.85
existsMethod · 0.45
updateMethod · 0.45
discardMethod · 0.45

Tested by

no test coverage detected