pub struct PackageRegistry { /* private fields */ }Expand description
Registry for package categorization
Maintains lists of known standard library and third-party packages. These can be updated by users to handle custom packages or different Python versions.
Implementations§
Source§impl PackageRegistry
impl PackageRegistry
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new registry with default Python 3.13 stdlib and common third-party packages
Sourcepub fn is_third_party(&self, package: &str) -> bool
pub fn is_third_party(&self, package: &str) -> bool
Check if a package is a known third-party package
Sourcepub fn add_stdlib_package(&mut self, package: impl Into<String>) -> &mut Self
pub fn add_stdlib_package(&mut self, package: impl Into<String>) -> &mut Self
Add a package to the standard library registry
§Examples
use py_import_helper::ImportHelper;
let mut helper = ImportHelper::new();
helper.registry_mut().add_stdlib_package("my_custom_stdlib");Sourcepub fn add_third_party_package(
&mut self,
package: impl Into<String>,
) -> &mut Self
pub fn add_third_party_package( &mut self, package: impl Into<String>, ) -> &mut Self
Add a package to the third-party registry
§Examples
use py_import_helper::ImportHelper;
let mut helper = ImportHelper::new();
helper.registry_mut().add_third_party_package("my_company_lib");Sourcepub fn remove_stdlib_package(&mut self, package: &str) -> &mut Self
pub fn remove_stdlib_package(&mut self, package: &str) -> &mut Self
Remove a package from the standard library registry
Sourcepub fn remove_third_party_package(&mut self, package: &str) -> &mut Self
pub fn remove_third_party_package(&mut self, package: &str) -> &mut Self
Remove a package from the third-party registry
Sourcepub fn clear_stdlib_packages(&mut self) -> &mut Self
pub fn clear_stdlib_packages(&mut self) -> &mut Self
Clear all standard library packages
Sourcepub fn clear_third_party_packages(&mut self) -> &mut Self
pub fn clear_third_party_packages(&mut self) -> &mut Self
Clear all third-party packages
Sourcepub fn add_stdlib_packages(&mut self, packages: &[&str]) -> &mut Self
pub fn add_stdlib_packages(&mut self, packages: &[&str]) -> &mut Self
Add multiple standard library packages at once
Sourcepub fn add_third_party_packages(&mut self, packages: &[&str]) -> &mut Self
pub fn add_third_party_packages(&mut self, packages: &[&str]) -> &mut Self
Add multiple third-party packages at once
Sourcepub fn reset_stdlib_to_defaults(&mut self) -> &mut Self
pub fn reset_stdlib_to_defaults(&mut self) -> &mut Self
Reset to default stdlib packages (Python 3.13)
Sourcepub fn reset_third_party_to_defaults(&mut self) -> &mut Self
pub fn reset_third_party_to_defaults(&mut self) -> &mut Self
Reset to default third-party packages
Sourcepub fn count_stdlib_packages(&self) -> usize
pub fn count_stdlib_packages(&self) -> usize
Get count of registered stdlib packages
Sourcepub fn count_third_party_packages(&self) -> usize
pub fn count_third_party_packages(&self) -> usize
Get count of registered third-party packages
Trait Implementations§
Source§impl Clone for PackageRegistry
impl Clone for PackageRegistry
Source§fn clone(&self) -> PackageRegistry
fn clone(&self) -> PackageRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more