returns imported module
    check if is ``leonardo_module_conf`` specified and then import them
545924
def _get_correct_module(mod):
    

    module_location = getattr(
        mod, 'leonardo_module_conf',
        getattr(mod, "LEONARDO_MODULE_CONF", None))
    if module_location:
        mod = import_module(module_location)

    elif hasattr(mod, 'default_app_config'):
        # use django behavior
        mod_path, _, cls_name = mod.default_app_config.rpartition('.')
        _mod = import_module(mod_path)
        config_class = getattr(_mod, cls_name)
        # check if is leonardo config compliant
        if _is_leonardo_module(config_class):
            mod = config_class

    return mod
697559
def _import_component(name):
    
    for f in (_get_from_module, _get_from_class):
        try:
            return f(name)
        except:
            pass
    log.debug("Couldn't load %s" % name)
1294298
def _ffi_module(self):
    """"""
    native_bin_dir = os.path.dirname(self.binary)
    logger.debug('loading native engine python module from: %s', native_bin_dir)
    sys.path.insert(0, native_bin_dir)
    return importlib.import_module(NATIVE_ENGINE_MODULE)
350656
def import_generated_autoboto_module(self, name):
        
        if str(self.config.build_dir) not in sys.path:
            sys.path.append(str(self.config.build_dir))
        return importlib.import_module(f"{self.config.target_package}.{name}")
820790
def check_imported(module):
        
        imported = True
        module_info = ('', '', '')
        # TODO: if possible, update to a cleaner method that doesn't require importing the module
        # and running inline code.
        try:
            importlib.import_module(module)
            module_info = imp.find_module(module)
        except ImportError:
            imported = False

        # get module path
        module_path = module_info[1]
        description = module_info[2]

        if not description:
            # if description is None or empty string the module could not be imported
            imported = False
        elif not description and not module_path:
            # if description/module_path are None or empty string the module could not be imported
            imported = False
        elif module_path is not None and (
            'dist-packages' in module_path or 'site-packages' in module_path
        ):
            # if dist-packages|site-packages in module_path the import doesn't count
            imported = False
        return imported
1107649
def import_from(module, name):
    '''
    
    '''
    module = importlib.import_module(module)
    return getattr(module, name)
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
1181853
def import_module(module_name):
    """"""
    import sys, os
    import importlib
    sys.path.append(os.path.dirname(__file__))
    return importlib.import_module(module_name)
34537
def find_module(module, path=None, imp=None):
    """"""
    if imp is None:
        imp = importlib.import_module
    with cwd_in_path():
        if "." in module:
            last = None
            parts = module.split(".")
            for i, part in enumerate(parts[:-1]):
                mpart = imp(".".join(parts[:i + 1]))
                try:
                    path = mpart.__path__
                except AttributeError:
                    raise NotAPackage(module)
                last = _imp.find_module(parts[i + 1], path)
            return last
        return _imp.find_module(module)
1244340
def cfg(self):
        
        config = LStruct(self.defaults)
        module = config['CONFIG'] = os.environ.get(
            CONFIGURATION_ENVIRON_VARIABLE, config['CONFIG'])

        if module:
            try:
                module = import_module(module)
                config.update({
                    name: getattr(module, name) for name in dir(module)
                    if name == name.upper() and not name.startswith('_')
                })

            except ImportError as exc:
                config.CONFIG = None
                self.logger.error("Error importing %s: %s", module, exc)

        # Patch configuration from ENV
        for name in config:
            if name.startswith('_') or name != name.upper() or name not in os.environ:
                continue
            try:
                config[name] = json.loads(os.environ[name])
            except ValueError:
                pass

        return config
234231
def get_module_doc(module, config=default_config, already_met=None):
    """"""
    # Avoid recursion loops (init)
    if already_met is None:
        already_met = set()

    if config.exclude_module:
        for ex in config.exclude_module:
            if ex.match(module.__name__):
                return None

    # Force load submodules into module's dict
    if hasattr(module, '__path__'):
        subm = [
            modname for importer, modname, ispkg
            in pkgutil.iter_modules(module.__path__)
        ]
        __import__(module.__name__, fromlist=subm)

    # We don't want to include imported items,
    # so we parse the code to blacklist them.

    # Be sure to parse .py and not .pyc file on Python 2.X
    if hasattr(module, '__file__'):
        module_file = module.__file__
    else:
        module_file = inspect.getsourcefile(module)
    path, ext = os.path.splitext(module_file)
    if ext == '.pyc':
        module_file = path + '.py'

    try:
        code = open(module_file).read()
        body = ast.parse(code).body
    except SyntaxError:
        code = open(module_file).read().encode('utf-8')
        body = ast.parse(code).body

    imported = []
    for node in body:
        if isinstance(node, (ast.Import, ast.ImportFrom)):
            imported.extend([n.name for n in node.names])

    nested_doc = []
    module_dict = module.__dict__

    for item in dir(module):
        if item not in imported and item in module_dict.keys():
            # Avoid recursion loops
            if id(item) in already_met:
                continue
            already_met.add(id(item))

            appended = None
            if isinstance(module_dict[item], types.ModuleType):
                appended = get_module_doc(module_dict[item], config, already_met)  # noqa
            elif isinstance(module_dict[item], type):
                appended = get_class_doc(module_dict[item], config)
            elif isinstance(module_dict[item], types.FunctionType):
                appended = get_function_doc(module_dict[item], config)
            if appended is not None:
                nested_doc.append(appended)

    return _doc_object(module, 'module', nested_doc, config)
764574
def import_module_or_none(module_label):
    
    try:
        # On Python 3, importlib has much more functionality compared to Python 2.
        return importlib.import_module(module_label)
    except ImportError:
        # Based on code from django-oscar:
        # There are 2 reasons why there could be an ImportError:
        #
        #  1. Module does not exist. In that case, we ignore the import and return None
        #  2. Module exists but another ImportError occurred when trying to import the module.
        #     In that case, it is important to propagate the error.
        #
        # ImportError does not provide easy way to distinguish those two cases.
        # Fortunately, the traceback of the ImportError starts at __import__
        # statement. If the traceback has more than one frame, it means that
        # application was found and ImportError originates within the local app
        __, __, exc_traceback = sys.exc_info()
        frames = traceback.extract_tb(exc_traceback)
        frames = [f for f in frames
                  if f[0] != "<frozen importlib._bootstrap>" and  # Python 3.6
                  f[0] != IMPORT_PATH_IMPORTLIB and
                  not f[0].endswith(IMPORT_PATH_GEVENT) and
                  not IMPORT_PATH_PYDEV in f[0]]
        if len(frames) > 1:
            raise
    return None
505885
def try_import(module_name, names=None, default=ImportErrorModule, warn=True):
    
    try:
        module = importlib.import_module(module_name)
    except ImportError:
        if warn:
            if warn is True:
                Config.utils_logger.warning(
                    "Module `%s` not found. Install it to remove this warning"
                    % module_name
                )
            else:
                warn(module_name, names, default)
        module = (
            ImportErrorModule(module_name) if default is ImportErrorModule else default
        )
    if not names:
        return module
    if not isinstance(names, (tuple, set, list)):
        names = [names]
    result = []
    for name in names:
        if hasattr(module, name):
            result.append(module.__getattribute__(name))
        else:
            result.append(
                ImportErrorModule("%s.%s" % (module_name, name))
                if default is ImportErrorModule
                else default
            )
    return result[0] if len(result) == 1 else result
641004
def import_optional(mod_name):
    ''' 

    '''
    try:
        return import_module(mod_name)
    except ImportError:
        pass
    except Exception:
        msg = "Failed to import optional module `{}`".format(mod_name)
        log.exception(msg)
679521
def _import_attr_n_module(module_name, attr):
    
    __import__(module_name)
    module = sys.modules[module_name]
    attr = getattr(module, attr)
    return attr, module
345256
def is_a_module(self, module_type):
        
        if hasattr(self, 'type'):
            return module_type in self.type
        return module_type in self.module_types
959039
def import_generated_autoboto(self):
        
        if str(self.config.build_dir) not in sys.path:
            sys.path.append(str(self.config.build_dir))
        return importlib.import_module(self.config.target_package)