Loads overrides for an introspection module.

    Either returns the same module again in case there are no overrides or a
    proxy module including overrides. Doesn't cache the result.
492936
def load_overrides(introspection_module):
    

    namespace = introspection_module.__name__.rsplit(".", 1)[-1]
    module_keys = [prefix + "." + namespace for prefix in const.PREFIX]

    # We use sys.modules so overrides can import from gi.repository
    # but restore everything at the end so this doesn't have any side effects
    for module_key in module_keys:
        has_old = module_key in sys.modules
        old_module = sys.modules.get(module_key)

    # Create a new sub type, so we can separate descriptors like
    # _DeprecatedAttribute for each namespace.
    proxy_type = type(namespace + "ProxyModule", (OverridesProxyModule, ), {})

    proxy = proxy_type(introspection_module)
    for module_key in module_keys:
        sys.modules[module_key] = proxy

    try:
        override_package_name = 'pgi.overrides.' + namespace

        # http://bugs.python.org/issue14710
        try:
            override_loader = get_loader(override_package_name)

        except AttributeError:
            override_loader = None

        # Avoid checking for an ImportError, an override might
        # depend on a missing module thus causing an ImportError
        if override_loader is None:
            return introspection_module

        override_mod = importlib.import_module(override_package_name)

    finally:
        for module_key in module_keys:
            del sys.modules[module_key]
            if has_old:
                sys.modules[module_key] = old_module

    override_all = []
    if hasattr(override_mod, "__all__"):
        override_all = override_mod.__all__

    for var in override_all:
        try:
            item = getattr(override_mod, var)
        except (AttributeError, TypeError):
            # Gedit puts a non-string in __all__, so catch TypeError here
            continue
        # make sure new classes have a proper __module__
        try:
            if item.__module__.split(".")[-1] == namespace:
                item.__module__ = namespace
        except AttributeError:
            pass
        setattr(proxy, var, item)

    # Replace deprecated module level attributes with a descriptor
    # which emits a warning when accessed.
    for attr, replacement in _deprecated_attrs.pop(namespace, []):
        try:
            value = getattr(proxy, attr)
        except AttributeError:
            raise AssertionError(
                "%s was set deprecated but wasn't added to __all__" % attr)
        delattr(proxy, attr)
        deprecated_attr = _DeprecatedAttribute(
            namespace, attr, value, replacement)
        setattr(proxy_type, attr, deprecated_attr)

    return proxy
460789
public static MetaClassRegistry getInstance(int includeExtension) {
        if (includeExtension != DONT_LOAD_DEFAULT) {
            if (instanceInclude == null) {
                instanceInclude = new MetaClassRegistryImpl();
            }
            return instanceInclude;
        } else {
            if (instanceExclude == null) {
                instanceExclude = new MetaClassRegistryImpl(DONT_LOAD_DEFAULT);
            }
            return instanceExclude;
        }
    }
431548
function loadModule (baseLoader, fromDir, fromFile, item, opts) {
      var modulePath = item.from;
      var possibilities = util.resolveModulePath(modulePath, fromDir);
      for (var i = 0, p; p = possibilities[i]; ++i) {
        var path = possibilities[i].path;
        if (!opts.reload && (path in jsio.__modules)) {
          return possibilities[i];
        }

        if (path in failedFetch) { possibilities.splice(i--, 1); }
      }

      if (!possibilities.length) {
        if (opts.suppressErrors) { return false; }
        var e = new Error('Could not import `' + item.from + '`'
            + "\tImport Stack:\n"
            + "\t\t" + processStack().join("\n\t\t"));
        e.jsioLogged = true;
        e.code = MODULE_NOT_FOUND;
        throw e;
      }

      var moduleDef = findModule(possibilities);
      if (!moduleDef) {
        if (opts.suppressErrors) { return false; }
        var paths = [];
        for (var i = 0, p; p = possibilities[i]; ++i) { paths.push(p.path); }
        var e = new Error("Could not import `" + modulePath + "`\n"
          + "\tlooked in:\n"
            + "\t\t" + paths.join('\n\t\t') + "\n"
            + "\tImport Stack:\n"
            + "\t\t" + processStack().join("\n\t\t"));
        e.code = MODULE_NOT_FOUND;
        throw e;
      }

      // a (potentially) nicer way to refer to a module -- how it was referenced in code when it was first imported
      moduleDef.friendlyPath = modulePath;

      // cache the base module's path in the path cache so we don't have to
      // try out all paths the next time we see the same base module.
      if (moduleDef.baseMod && !(moduleDef.baseMod in jsioPath.cache)) {
        jsioPath.cache[moduleDef.baseMod] = moduleDef.basePath;
      }

      // don't apply the standard preprocessors to base.js.  If we're reloading
      // the source code, always apply them.  We also don't want to run them
      // if they've been run once -- moduleDef.pre is set to true already
      // if we're reading the code from the source cache.
      if (modulePath != 'base' && (opts.reload || !opts.dontPreprocess && !moduleDef.pre)) {
        moduleDef.pre = true;

        applyPreprocessors(fromDir, moduleDef, ["import", "inlineSlice"], opts);
      }

      // any additional preprocessors?
      if (opts.preprocessors) {
        applyPreprocessors(fromDir, moduleDef, opts.preprocessors, opts);
      }

      return moduleDef;
    }
1304329
def load(self, _=None):
        
        for k, v in self.layer.iteritems():
            self.add(k, v['module'], v.get('package'))
319219
def auto_override_module(md, force_recursive = False):
    
    if not pytypes.checking_enabled:
        return md
    if isinstance(md, str):
        if md in sys.modules:
            md = sys.modules[md]
            if md is None:
                return md
        elif md in _pending_modules:
            # if import is pending, we just store this call for later
            _pending_modules[md].append(lambda t: auto_override_module(t, True))
            return md
    assert(ismodule(md))
    if md.__name__ in _pending_modules:
            # if import is pending, we just store this call for later
            _pending_modules[md.__name__].append(lambda t: auto_override_module(t, True))
            # we already process the module now as far as possible for its internal use
            # todo: Issue warning here that not the whole module might be covered yet
    if md.__name__ in _auto_override_modules and \
            _auto_override_modules[md.__name__] == len(md.__dict__):
        return md
    # To play it safe we avoid to modify the dict while iterating over it,
    # so we previously cache keys.
    # For this we don't use keys() because of Python 3.
    # Todo: Better use inspect.getmembers here
    keys = [key for key in md.__dict__]
    for key in keys:
        memb = md.__dict__[key]
        if force_recursive or not is_no_type_check(memb):
            if isclass(memb) and memb.__module__ == md.__name__:
                auto_override_class(memb, force_recursive, force_recursive)
    if not md.__name__ in _pending_modules:
        _auto_override_modules[md.__name__] = len(md.__dict__)
    return md
688008
def load_module(self, loader):
        '''
        
        '''

        modfile, pathname, description = loader.info
        module = imp.load_module(
            loader.fullname,
            modfile,
            pathname,
            description
        )
        sys.modules[loader.fullname] = module
        self.__loaded_modules.add(loader.fullname)

        autodecorator.decorate_module(module, decorator=self.__decorator)

        return module
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)
1356135
def load_module(self, fullname):
        
        mod = super(JsonLoader, self).load_module(fullname)

        try:
            with codecs.open(self.cfg_file, 'r', 'utf-8') as f:
                mod.__dict__.update(json.load(f))
        except ValueError:
            # if raise here, traceback will contain ValueError
            self.e = "ValueError"
            self.err_msg = sys.exc_info()[1]

        if self.e == "ValueError":
            err_msg = "\nJson file not valid: "
            err_msg += self.cfg_file + '\n'
            err_msg += str(self.err_msg)
            raise InvalidJsonError(err_msg)

        return mod
51610
def load_module(self, name):
        
        if name in sys.modules:
            return sys.modules[name]
        module_source = self.module2uri(name)
        module_container = tempfile.NamedTemporaryFile(suffix='.py', delete=False)
        with module_container:
            module_container.write(module_source)
            module_container.file.seek(0)
            module = imp.load_module(name, module_container.file, module_container.name, ('.py', 'U', imp.PY_SOURCE))
        module.__source__ = module_container
        module.__loader__ = self
        sys.modules[name] = module
        return module
643403
def loadInstance(self):
        
        if self._loaded:
            return

        self._loaded = True
        module_path = self.modulePath()

        package = projex.packageFromPath(module_path)
        path = os.path.normpath(projex.packageRootPath(module_path))

        if path in sys.path:
            sys.path.remove(path)

        sys.path.insert(0, path)

        try:
            __import__(package)

        except Exception, e:
            err = Plugin(self.name(), self.version())
            err.setError(e)
            err.setFilepath(module_path)

            self._instance = err

            self.setError(e)

            msg = "%s.plugin('%s') errored loading instance from %s"
            opts = (self.proxyClass().__name__, self.name(), module_path)
            logger.warning(msg % opts)
            logger.error(e)
1138901
def _get_all(self, _type):
        
        if _type not in self.modules:
            raise ValueError("No such module, %s" % _type)
        if not self.insts_implementing.get(_type, None):
            raise ValueError("No instance implementing %s" % _type)
        return self.insts_implementing[_type]
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))
1318525
function fetchGetModule(data, callback) {
    var fullModuleName = data.moduleName;

    // try and load the module the old way...
    console.log("loadModule("+fullModuleName+")");

    var urls = []; // Array of where to look for this module
    var modName; // Simple name of the module
    if(Espruino.Core.Utils.isURL(fullModuleName)) {
      modName = fullModuleName.substr(fullModuleName.lastIndexOf("/") + 1).split(".")[0];
      urls = [ fullModuleName ];
    } else {
      modName = fullModuleName;
      Espruino.Config.MODULE_URL.split("|").forEach(function (url) {
        url = url.trim();
        if (url.length!=0)
        Espruino.Config.MODULE_EXTENSIONS.split("|").forEach(function (extension) {
          urls.push(url + "/" + fullModuleName + extension);
        })
      });
    };

    // Recursively go through all the urls
    (function download(urls) {
      if (urls.length==0) {
        return callback(data);
      }
      var dlUrl = urls[0];
      Espruino.Core.Utils.getURL(dlUrl, function (code) {
        if (code!==undefined) {
          // we got it!
          data.moduleCode = code;
          data.isMinified = dlUrl.substr(-7)==".min.js";
          return callback(data);
        } else {
          // else try next
          download(urls.slice(1));
        }
      });
    })(urls);
  }
278045
protected function loadOverrides()
    {
        if ($this->overrides === null) {
            $this->overrides = [];

            if ($this->overrideFile !== null) {
                $this->overrides = Craft::$app->getConfig()->getConfigFromFile($this->overrideFile);
            }
        }
    }
147797
def load(self):
        

        # Must reverse because we want the sources assigned to higher-up Config instances
        # to overrides sources assigned to lower Config instances.
        for section in reversed(list(self.iter_sections(recursive=True, key=None))):
            if section.is_config:
                section.load()

        for source in self.settings.load_sources:
            adapter = getattr(self, _get_persistence_adapter_for(source))
            if adapter.store_exists(source):
                adapter.load(source)
340435
def load_module(self, module):
        
        cases = self.get_test_cases_from_module(module)
        suites = [self.load_case(case) for case in cases]
        return self.create_suite(suites)
77536
function getModule (name) {
    // create new module if it does not already exist
    if (!defined(immutableApp.modules[name])) {
        // create module
        immutableApp.modules[name] = new ImmutableAppModule(name)
        // add to list
        immutableApp.moduleNames.push(name)
    }
    // return module
    return immutableApp.modules[name]
}