Load the named module without registering it in ``sys.modules``.

    Parameters
    ----------
    name : string
      Module name

    Returns
    -------
    mod : module
      Loaded module
166730
def load_module(name):
    

    spec = importlib.util.find_spec(name)
    mod = importlib.util.module_from_spec(spec)
    mod.__spec__ = spec
    mod.__loader__ = spec.loader
    spec.loader.exec_module(mod)
    return mod
164772
def named_module(name):
    """"""
    module = __import__(name)
    packages = name.split(".")[1:]
    m = module
    for p in packages:
        m = getattr(m, p)
    return m
478058
def import_name(name):
    
    if isinstance(name, str):
        components = name.split('.')
        mod = __import__('.'.join(components[0:-1]), globals(), locals(), [components[-1]] )
        return getattr(mod, components[-1])
    else:
        return name
213353
def load_module(self, name):
        
        # allow reload noop
        if name in sys.modules:
            return sys.modules[name]
        raise DisabledIncludeError('Include type %r disabled, cannot import module %r' % (self._module_prefix, name))
1181853
def import_module(module_name):
    """"""
    import sys, os
    import importlib
    sys.path.append(os.path.dirname(__file__))
    return importlib.import_module(module_name)
224087
def register_module(self, module, namespace=None):
        
        namespace = namespace if namespace is not None else module \
            if isinstance(module, str) else module.__name__
        self.register_namespace(namespace, module)
117569
def get(self, name):
        """"""
        if name not in self.modules:
            self.load_dependency(name, False, False, False)

        if name in self.modules:
            return self.modules[name]
        else:
            return None
1145564
def load_module(filename):
    
    path, name = os.path.split(filename)
    name, ext = os.path.splitext(name)
    (file, filename, desc) = imp.find_module(name, [path])

    try:
        return imp.load_module(name, file, filename, desc)
    finally:
        if file:
            file.close()
106538
def load_module(self, name):
        

        # Get the name relative to SITEDIR ..
        filepath = self.module_info[1]
        fullname = splitext( \
            relpath(filepath, self.sitedir) \
            )[0].replace(os.sep, '.')

        modulename = filename_to_module(fullname)
        if modulename not in allowed_modules:
            if remember_blocks:
                blocked_imports.add(fullname)
            if log_blocks:
                raise ImportError("Vext blocked import of '%s'" % modulename)
            else:
                # Standard error message
                raise ImportError("No module named %s" % modulename)

        if name not in sys.modules:
            try:
                logger.debug("load_module %s %s", name, self.module_info)
                module = imp.load_module(name, *self.module_info)
            except Exception as e:
                logger.debug(e)
                raise
            sys.modules[fullname] = module

        return sys.modules[fullname]
1120747
def modprobe(state, host, name, present=True, force=False):
    '''
    
    '''

    modules = host.fact.kernel_modules
    is_present = name in modules

    args = ''
    if force:
        args = ' -f'

    # Module is loaded and we don't want it?
    if not present and is_present:
        yield 'modprobe{0} -r {1}'.format(args, name)

    # Module isn't loaded and we want it?
    elif present and not is_present:
        yield 'modprobe{0} {1}'.format(args, name)
1349679
def import_object(modname, name):
    
    try:
        __import__(modname)
        mod = sys.modules[modname]
        obj = mod
        for part in name.split('.'):
            obj = getattr(obj, part)
        return obj
    except:
        return None
423183
def get_module(self, module_name):
        """"""
        try:
            return self.module[module_name]

        except KeyError:
            return sys.modules[module_name]
1183074
def import_module(name: str) -> ModuleType:
    
    logger.debug("Importing module: %s", name)
    if name == main_module_name():
        return main_module

    return importlib.import_module(name)
617976
def load_object_by_name(object_name):
    """"""
    mod_name, attr = object_name.rsplit('.', 1)
    mod = import_module(mod_name)
    return getattr(mod, attr)
17200
def load_module(self, module):
        
        # pylint: disable=unused-variable
        for name, obj in inspect.getmembers(module,
                                            lambda member: hasattr(member, '__module__')
                                            and member.__module__ == module.__name__
                                            and inspect.isclass):
            self.load_class(obj)
902188
def load_module(self, name):
        
        # Implementation inspired from pytest.rewrite and importlib

        # If there is an existing module object named 'name' in
        # sys.modules, the loader must use that existing module. (Otherwise,
        # the reload() builtin will not work correctly.)
        if name in sys.modules:
            return sys.modules[name]
        try:
            # we have already done the search, an gone through package layers
            # so we directly feed the latest module and correct path
            # to reuse the logic for choosing the proper loading behavior

            # TODO : double check maybe we do not need the loop here, already handled by finders in dir hierarchy
            # TODO : use exec_module (recent, more tested API) from here
            for name_idx, name_part in enumerate(name.split('.')):
                pkgname = ".".join(name.split('.')[:name_idx+1])
                if pkgname not in sys.modules:
                    if '.' in pkgname:
                        # parent has to be in sys.modules. make sure it is a package, else fails
                        if '__path__' in vars(sys.modules[pkgname.rpartition('.')[0]]):
                            path = sys.modules[pkgname.rpartition('.')[0]].__path__
                        else:
                            raise ImportError("{0} is not a package (no __path__ detected)".format(pkgname.rpartition('.')[0]))
                    else:  # using __file__ instead. should always be there.
                        path = os.path.dirname(sys.modules[pkgname].__file__)if pkgname in sys.modules else None
                    try:
                        file, pathname, description = imp.find_module(pkgname.rpartition('.')[-1], path)
                        sys.modules[pkgname] = imp.load_module(pkgname, file, pathname, description)
                    finally:
                        if file:
                            file.close()
        except:
            # dont pollute the interpreter environment if we dont know what we are doing
            if name in sys.modules:
                del sys.modules[name]
            raise
        return sys.modules[name]
1076719
def import_name(mod_name):
    
    try:
        mod_obj_old = sys.modules[mod_name]
    except KeyError:
        mod_obj_old = None

    if mod_obj_old is not None:
        return mod_obj_old

    __import__(mod_name)

    mod_obj = sys.modules[mod_name]

    return mod_obj