Files @ 2cd418e377de
Branch filter:

Location: kallithea/kallithea/lib/vcs/utils/fakemod.py

mads
vcs: replace imp with importlib

imp has been dropped in Python 3.12. Mercurial has been changed in a similar
way.
import importlib


def create_module(name, path):
    """
    Returns module created *on the fly*. Returned module would have name same
    as given ``name`` and would contain code read from file at the given
    ``path`` (it may also be a zip or package containing *__main__* module).
    """

    spec = importlib.util.spec_from_file_location('module_name', path)
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
    return module