PythonProject

Struct PythonProject 

Source
pub struct PythonProject {
    pub root_dir: PathBuf,
    pub module_map: HashMap<String, PathBuf>,
    pub file_contents: HashMap<PathBuf, String>,
    pub dependencies: HashMap<String, HashSet<String>>,
    pub circular_dependencies: HashMap<String, HashSet<String>>,
    pub dynamic_imports: HashMap<String, Vec<String>>,
    pub star_imports: HashMap<String, Vec<String>>,
    pub import_aliases: HashMap<String, HashMap<String, String>>,
    pub conditional_imports: HashMap<String, Vec<ConditionalImport>>,
}
Expand description

Structure representing a Python project

Fields§

§root_dir: PathBuf

Root directory of the project

§module_map: HashMap<String, PathBuf>

Map of module paths to file paths

§file_contents: HashMap<PathBuf, String>

Map of file paths to their content

§dependencies: HashMap<String, HashSet<String>>

Dependency graph between modules

§circular_dependencies: HashMap<String, HashSet<String>>

Map to track circular dependencies

§dynamic_imports: HashMap<String, Vec<String>>

Map of modules that use dynamic imports

§star_imports: HashMap<String, Vec<String>>

Map of modules that use star imports

§import_aliases: HashMap<String, HashMap<String, String>>

Map to track import aliases

§conditional_imports: HashMap<String, Vec<ConditionalImport>>

Map of conditional imports (in try-except blocks)

Implementations§

Source§

impl PythonProject

Source

pub fn from_directory(dir: impl AsRef<Path>) -> Result<Self>

Create a new Python project from a directory

Source

pub fn get_ordered_files(&self) -> Result<Vec<(PathBuf, String)>>

Get all files in topological order (dependencies first)

Source

pub fn get_module_contents(&self) -> Vec<(String, (PathBuf, String))>

Get a map of module paths to (file_path, content) pairs

Source

pub fn get_ir_imports(&self, module_path: &str) -> Vec<IRImport>

Convert all imports to IRImport objects

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, U> ExactFrom<T> for U
where U: TryFrom<T>,

Source§

fn exact_from(value: T) -> U

Source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

Source§

fn exact_into(self) -> U

§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

Source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

Source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

Source§

fn wrapping_into(self) -> U