Skip to main content

Module python_resolver

Module python_resolver 

Source
Expand description

Python module resolver — maps dotted import paths to file paths.

Builds a module index from a directory tree by walking __init__.py locations and file paths, then resolves imports (absolute and relative) to their corresponding source files.

§Usage

let resolver = PythonModuleResolver::from_root(Path::new("_archive/brain-v13/brain/"))?;

// Resolve an absolute import
let path = resolver.resolve_import("brain.perception.signal_fusion", None);
// → Some("_archive/brain-v13/brain/perception/signal_fusion.py")

// Resolve a relative import
let from_file = Path::new("brain/perception/assessors.py");
let path = resolver.resolve_import(".utils", Some(from_file));
// → Some("brain/perception/utils.py")

Structs§

PythonModuleResolver
Resolves Python import statements to file paths.

Enums§

ResolverError
Errors from the Python module resolver.