pub struct PyModuleMap { /* private fields */ }Implementations§
Source§impl PyModuleMap
impl PyModuleMap
pub fn build(files: &[SourceFile]) -> Self
pub fn module_of(&self, file_path: &str) -> Option<Vec<String>>
Sourcepub fn is_package(&self, file_path: &str) -> bool
pub fn is_package(&self, file_path: &str) -> bool
True when the file is a package __init__.py (its module key IS its package).
pub fn resolve_absolute(&self, dotted: &str) -> Option<Vec<String>>
Sourcepub fn resolve_relative(
&self,
referencing: &[String],
is_package: bool,
level: usize,
suffix: &str,
) -> Option<Vec<String>>
pub fn resolve_relative( &self, referencing: &[String], is_package: bool, level: usize, suffix: &str, ) -> Option<Vec<String>>
Resolve a relative import. The relative anchor is the importing module’s
PACKAGE: the key itself when the importer is a package __init__.py
(is_package), else the key minus its module stem. level dots then walk
up level-1 more packages from that anchor (Python: level 1 = the package
containing the importer). This is_package distinction is REQUIRED — a key
like ["pkg","sub"] is ambiguous (regular module pkg/sub.py vs package
pkg/sub/__init__.py) and the two anchor differently.
Auto Trait Implementations§
impl Freeze for PyModuleMap
impl RefUnwindSafe for PyModuleMap
impl Send for PyModuleMap
impl Sync for PyModuleMap
impl Unpin for PyModuleMap
impl UnsafeUnpin for PyModuleMap
impl UnwindSafe for PyModuleMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more