Struct python_packaging::resource::PythonModuleSource
source · pub struct PythonModuleSource {
pub name: String,
pub source: FileData,
pub is_package: bool,
pub cache_tag: String,
pub is_stdlib: bool,
pub is_test: bool,
}
Expand description
A Python module defined via source code.
Fields§
§name: String
The fully qualified Python module name.
source: FileData
Python source code.
is_package: bool
Whether this module is also a package.
cache_tag: String
Tag to apply to bytecode files.
e.g. cpython-39
.
is_stdlib: bool
Whether this module belongs to the Python standard library.
Modules with this set are distributed as part of Python itself.
is_test: bool
Whether this module is a test module.
Test modules are those defining test code and aren’t critical to run-time functionality of a package.
Implementations§
source§impl PythonModuleSource
impl PythonModuleSource
pub fn description(&self) -> String
pub fn to_memory(&self) -> Result<Self>
sourcepub fn package(&self) -> String
pub fn package(&self) -> String
Resolve the package containing this module.
If this module is a package, returns the name of self.
sourcepub fn top_level_package(&self) -> &str
pub fn top_level_package(&self) -> &str
Obtain the top-level package name this module belongs to.
sourcepub fn as_bytecode_module(
&self,
optimize_level: BytecodeOptimizationLevel
) -> PythonModuleBytecodeFromSource
pub fn as_bytecode_module(
&self,
optimize_level: BytecodeOptimizationLevel
) -> PythonModuleBytecodeFromSource
Convert the instance to a BytecodeModule.
sourcepub fn resolve_path(&self, prefix: &str) -> PathBuf
pub fn resolve_path(&self, prefix: &str) -> PathBuf
Resolve the filesystem path for this source module.
sourcepub fn has_dunder_file(&self) -> Result<bool>
pub fn has_dunder_file(&self) -> Result<bool>
Whether the source code for this module has file
Trait Implementations§
source§impl Clone for PythonModuleSource
impl Clone for PythonModuleSource
source§fn clone(&self) -> PythonModuleSource
fn clone(&self) -> PythonModuleSource
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for PythonModuleSource
impl Debug for PythonModuleSource
source§impl<'a> From<&'a PythonModuleSource> for PythonResource<'a>
impl<'a> From<&'a PythonModuleSource> for PythonResource<'a>
source§fn from(m: &'a PythonModuleSource) -> Self
fn from(m: &'a PythonModuleSource) -> Self
Converts to this type from the input type.
source§impl<'a> From<PythonModuleSource> for PythonResource<'a>
impl<'a> From<PythonModuleSource> for PythonResource<'a>
source§fn from(m: PythonModuleSource) -> Self
fn from(m: PythonModuleSource) -> Self
Converts to this type from the input type.
source§impl PartialEq<PythonModuleSource> for PythonModuleSource
impl PartialEq<PythonModuleSource> for PythonModuleSource
source§fn eq(&self, other: &PythonModuleSource) -> bool
fn eq(&self, other: &PythonModuleSource) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.