polymerist.genutils.importutils.pyimports

For inspecting and managing toplevel imports within Python files and modules

Classes

ImportedObjectInfo

For encapsulating info about an object imported in a Python file

Functions

extract_imports_from_pyfile(→ list[ImportedObjectInfo])

Compiles info from all Python imports in a Python (.py) file

extract_imports_from_dir(→ list[ImportedObjectInfo])

Compiles info from all Python imports in any and all Python files in a directory

extract_imports_from_module(→ list[ImportedObjectInfo])

Compiles info from all Python imports in a Python (.py) file

Module Contents

class polymerist.genutils.importutils.pyimports.ImportedObjectInfo[source]

For encapsulating info about an object imported in a Python file

object_name: str
object_alias: str | None = None
parent_module: str | None = None
source_file: pathlib.Path | None = None
line_number: int | None = None
is_relative: bool | None = None
polymerist.genutils.importutils.pyimports.extract_imports_from_pyfile(pyfile_path: pathlib.Path) list[ImportedObjectInfo][source]

Compiles info from all Python imports in a Python (.py) file

polymerist.genutils.importutils.pyimports.extract_imports_from_dir(source_dir: pathlib.Path) list[ImportedObjectInfo][source]

Compiles info from all Python imports in any and all Python files in a directory

polymerist.genutils.importutils.pyimports.extract_imports_from_module(module: types.ModuleType) list[ImportedObjectInfo][source]

Compiles info from all Python imports in a Python (.py) file