Source code for pybert.utility.python

"""
General Python utilities for PyBERT.

Original author: David Banas <capn.freako@gmail.com>

Original date:   June 16, 2024

Copyright (c) 2024 David Banas; all rights reserved World wide.

A partial extraction of the old `pybert/utility.py`, as part of a refactoring.
"""

import importlib
import pkgutil


[docs] def submodules(package): """Find all sub-modules of a package.""" rst = {} for _, name, _ in pkgutil.iter_modules(package.__path__): fullModuleName = f"{package.__name__}.{name}" mod = importlib.import_module(fullModuleName, package=package.__path__) rst[name] = mod return rst