polymerist.genutils.importutils =============================== .. py:module:: polymerist.genutils.importutils .. autoapi-nested-parse:: Functionality for dynamically importing and inspecting Python modules and packages Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/polymerist/genutils/importutils/dependencies/index /autoapi/polymerist/genutils/importutils/pkginspect/index /autoapi/polymerist/genutils/importutils/pkgiter/index /autoapi/polymerist/genutils/importutils/pyimports/index Attributes ---------- .. autoapisummary:: polymerist.genutils.importutils.module_tree Functions --------- .. autoapisummary:: polymerist.genutils.importutils.module_hierarchy polymerist.genutils.importutils.iter_submodules polymerist.genutils.importutils.module_tree_direct polymerist.genutils.importutils.is_package polymerist.genutils.importutils.is_module Package Contents ---------------- .. py:function:: module_hierarchy(module: types.ModuleType, recursive: bool = True, blacklist: Optional[Container[str]] = None, style: Union[str, anytree.render.AbstractStyle] = ContStyle()) -> str Generates a printable string which summarizes a Python packages hierarchy. Reminiscent of GNU tree output :Parameters: * **module** (*ModuleType*) -- The "root" module to begin importing from Represented in the Node object returned by this function * **recursive** (*bool, default=True*) -- Whether or not to recursively import modules from subpackages and add them to the tree * **blacklist** (*Container[str] (optional)*) -- List of module names to exclude from tree building If provided, will exclude any modules whose names occur in this list * **style** (*str or AbstractStyle*) -- An element drawing style for the final tree structure printout :returns: **module_summary** -- Printable string which displays the package structure :rtype: str .. py:function:: iter_submodules(module: types.ModuleType, recursive: bool = True, blacklist: Optional[Container[str]] = None) -> Generator[types.ModuleType, None, None] Generates all modules which can be imported from the given toplevel module :Parameters: * **module** (*ModuleType*) -- The "root" module to begin importing from Represented in the Node object returned by this function * **recursive** (*bool, default=True*) -- Whether or not to recursively import modules from subpackages and add them to the tree * **blacklist** (*Container[str] (optional)*) -- List of module names to exclude from tree building If provided, will exclude any modules whose names occur in this list :returns: **submodules** -- A generator which yields modules in traversal pre-order as they appear wihin the package hierarchy :rtype: Generator[ModuleType] .. py:data:: module_tree .. py:function:: module_tree_direct(module: types.ModuleType, recursive: bool = True, blacklist: Optional[Container[str]] = None) -> anytree.node.Node Produce a tree from the Python package hierarchy starting with a given module :Parameters: * **module** (*ModuleType*) -- The "root" module to begin importing from Represented in the Node object returned by this function * **recursive** (*bool, default=True*) -- Whether or not to recursively import modules from subpackages and add them to the tree * **blacklist** (*Container[str] (optional)*) -- List of module names to exclude from tree building If provided, will exclude any modules whose names occur in this list :returns: **modtree** -- The root node of the module tree, corresponding to the module object passed to "module" :rtype: Node .. py:function:: is_package(package: importlib.resources.Package) -> bool Determine whether a given Package-like (i.e. str or ModuleType) is a valid Python package .. py:function:: is_module(module: importlib.resources.Package) -> bool 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