polymerist.genutils.importutils.pkginspect
For checking whether object are valid Python modules and packages, and if so for gathering info from within them
Functions
|
Determine whether a given Package-like (i.e. str or ModuleType) is a valid Python module |
|
Determine whether a given Package-like (i.e. str or ModuleType) is a valid Python package |
|
Flexible interface for supplying a ModuleType object as an argument |
|
Takes a module (as its name or as ModuleType) and returns its parent package name and relative module name |
|
Takes a module (as its name or as ModuleType) and returns its relative module name |
|
Gets the name of a module relative to another (presumably toplevel) module |
|
Get the Path to a resource (i.e. either a directory or a file) which lives within a Python package |
|
Get the Path to a directory which lives within a Python package |
|
Get the Path to a (non-directory) file which lives within a Python package |
Module Contents
- polymerist.genutils.importutils.pkginspect.is_module(module: importlib.resources.Package) bool[source]
Determine whether a given Package-like (i.e. str or ModuleType) is a valid Python module This will return True for packages, bottom-level modules (i.e. *.py) and Python scripts
- polymerist.genutils.importutils.pkginspect.is_package(package: importlib.resources.Package) bool[source]
Determine whether a given Package-like (i.e. str or ModuleType) is a valid Python package
- polymerist.genutils.importutils.pkginspect.flexible_module_pass(module: str | pathlib.Path | types.ModuleType) types.ModuleType[source]
Flexible interface for supplying a ModuleType object as an argument Allows for passing a name (either module name or string path), Path location, or a module proper
- polymerist.genutils.importutils.pkginspect.module_parts(module: str | types.ModuleType) tuple[str | None, str][source]
Takes a module (as its name or as ModuleType) and returns its parent package name and relative module name
- polymerist.genutils.importutils.pkginspect.module_stem(module: str | types.ModuleType) tuple[str | None, str][source]
Takes a module (as its name or as ModuleType) and returns its relative module name
- polymerist.genutils.importutils.pkginspect.relative_module_name(module: types.ModuleType, relative_to: types.ModuleType | None = None, remove_leading_dot: bool = True) str[source]
Gets the name of a module relative to another (presumably toplevel) module If the given module is not in the path of the toplevel module, will simply return as module.__name__
- polymerist.genutils.importutils.pkginspect.get_resource_path_within_package(relative_path: str | pathlib.Path, package: importlib.resources.Package) pathlib.Path[source]
Get the Path to a resource (i.e. either a directory or a file) which lives within a Python package