| Given a module `service`, try to import its models module.

    :param module: The module's name to import the models.
    :type module: str
    :rtype: list
    :returns: all the models defined.
494351
def import_models(module):
    
    try:
        module = importlib.import_module('{0}.models'.format(module))
    except ImportError:
        return []
    else:
        clsmembers = inspect.getmembers(module, lambda member: inspect.isclass(member) and member.__module__ == module.__name__)
        return [kls for name, kls in clsmembers]
990757
def load(self, modules):
        
        self.modules_assoc = []
        for module in modules:
            if not module.enabled:
                logger.info("Module %s is declared but not enabled", module.name)
                # Store in our modules list but do not try to load
                # Probably someone else will load this module later...
                self.modules[module.uuid] = module
                continue
            logger.info("Importing Python module '%s' for %s...", module.python_name, module.name)
            try:
                python_module = importlib.import_module(module.python_name)

                # Check existing module properties
                # Todo: check all mandatory properties
                if not hasattr(python_module, 'properties'):  # pragma: no cover
                    self.configuration_errors.append("Module %s is missing a 'properties' "
                                                     "dictionary" % module.python_name)
                    raise AttributeError
                logger.info("Module properties: %s", getattr(python_module, 'properties'))

                # Check existing module get_instance method
                if not hasattr(python_module, 'get_instance') or \
                        not isinstance(getattr(python_module, 'get_instance'),
                                       collections.Callable):  # pragma: no cover
                    self.configuration_errors.append("Module %s is missing a 'get_instance' "
                                                     "function" % module.python_name)
                    raise AttributeError

                self.modules_assoc.append((module, python_module))
                logger.info("Imported '%s' for %s", module.python_name, module.name)
            except ImportError as exp:  # pragma: no cover, simple protection
                self.configuration_errors.append("Module %s (%s) can't be loaded, Python "
                                                 "importation error: %s" % (module.python_name,
                                                                            module.name,
                                                                            str(exp)))
            except AttributeError:  # pragma: no cover, simple protection
                self.configuration_errors.append("Module %s (%s) can't be loaded, "
                                                 "module configuration" % (module.python_name,
                                                                           module.name))
            else:
                logger.info("Loaded Python module '%s' (%s)", module.python_name, module.name)
690437
def copy_models(module_from, module_to):
    
    module_from = get_module(module_from)
    module_to = get_module(module_to)
    models = get_models(module_from)
    if models:
        models = models.copy()
        models.update(((t.key, t) for t in module_tables(module_from)))
        module_to.__odm_models__ = models
        return models
29555
def load_modules_from_python(self, route_list):
        """"""
        for name, modpath in route_list:
            if ':' in modpath:
                path, attr = modpath.split(':', 1)
            else:
                path, attr = modpath, None
            self.commands[name] = ModuleLoader(path, attr=attr)
1230327
def import_module(path):
    
    mod = __import__(path, locals={}, globals={})
    for item in path.split('.')[1:]:
        try:
            mod = getattr(mod, item)
        except AttributeError:
            raise ImportError('No module named %s' % path)
    return mod
1107649
def import_from(module, name):
    '''
    
    '''
    module = importlib.import_module(module)
    return getattr(module, name)
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
946800
def reload_module(module):
    
    try:
        # For Python 2.x
        reload(module)
    except (ImportError, NameError):
        # For <= Python3.3:
        import imp
        imp.reload(module)
    except (ImportError, NameError):
        # For >= Python3.4
        import importlib
        importlib.reload(module)
1212518
def load_module(self, name):
        
        if name not in sys.modules:
            sys.modules[name] = getattr(maps, name.split('.')[2])
        return sys.modules[name]
587704
def get_module(mod_name):
    
    if mod_name is '':
        raise ImportError('Unable to import empty module')

    mod = __import__(mod_name)
    components = mod_name.split('.')

    for comp in components[1:]:
        mod = getattr(mod, comp)

    return mod
1343203
def register_module(module=None):
    

    global REGISTERED_MODULES

    if module is None:
        # Note: inspect.getmodule() can return the wrong module if it has been imported with different relatives paths.
        module = sys.modules.get(inspect.currentframe().f_back.f_globals["__name__"])

    REGISTERED_MODULES.add(module)
    return True
193651
def get_imported_modules(self, module):
    """"""
    for name, member in inspect.getmembers(module):
      if inspect.ismodule(member):
        yield name, member
1031658
public void findModules() {
        ServiceLoader<ClientModuleFactory> loader = ServiceLoader.load(ClientModuleFactory.class);

        Iterator<ClientModuleFactory> iterator = loader.iterator();
        while (iterator.hasNext()) {
            ClientModuleFactory factory = iterator.next();
            Module module = factory.create();
            addModule(module);
        }

        objectMapper.findAndRegisterModules();
    }
1029332
def get_modules(package_name, module_names):
  
  def get_module(name):
    return __import__(".".join([package_name, name]), fromlist=[package_name])
  return [get_module(name) for name in module_names]
1187769
def create(self, module_name, class_name,
               args=None, kwargs=None, factory_method=None,
               factory_args=None, factory_kwargs=None, static=False,
               calls=None):
        
        if args is None:
            args = []
        if kwargs is None:
            kwargs = {}
        if factory_args is None:
            factory_args = []
        if factory_kwargs is None:
            factory_kwargs = {}
        if static is None:
            static = False

        # Verify
        _verify_create_args(module_name, class_name, static)

        # Import
        module = _import_module(module_name)

        # Instantiate
        service_obj = self._instantiate(module, class_name,
                                        args, kwargs, static)
        # Factory?
        if factory_method is not None:
            service_obj = self._handle_factory_method(service_obj,
                                                      factory_method,
                                                      factory_args,
                                                      factory_kwargs)
        # Extra Calls
        if calls is not None and isinstance(calls, list):
            self._handle_calls(service_obj, calls)

        # Return
        return service_obj
483962
def migrate(module=None):
    
    if not module:
        #Parsing
        parser = argparse.ArgumentParser()
        parser.add_argument('-s', '--service', type=str, help='Migrate the module', required=True,
                            dest='module')
        args = parser.parse_args()
        module = args.module
    #1. Load settings
    farine.settings.load()
    #2. Load the module
    models = farine.discovery.import_models(module)
    #3. Get the connection
    db = farine.connectors.sql.setup(getattr(farine.settings, module))
    #4. Create tables
    for model in models:
        model._meta.database = db
        model.create_table(fail_silently=True)
732311
def load_model(self, config):
        
        for package_name in getattr(config.app, 'modules', []):
            module = __import__(package_name, fromlist=['model'])
            if hasattr(module, 'model'):
                return module.model
        return None