load a module from a file
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;
    }
1329584
def load_module(self, module):
        
        if isinstance(module, basestring) and module.find('.') > -1:
            a = module.split('.')
            module = ('.%s' % a[-1], '.'.join(a[:-1]))
        try:
            module = import_module(*module)
        except Exception, e:
            return e
        
        for name in dir(module):
            if name.startswith('_'): continue
            obj = getattr(module, name)
            if callable(obj):
                for tag in settings.TAG_TYPES:
                    if hasattr(obj, tag) and getattr(obj, tag) in (1, True):
                        name = getattr(obj, 'name', obj.__name__)
                        if name in self[tag]:
                            continue
                        if hasattr(obj, 'name'):
                            self.register(tag, getattr(obj, 'name'), obj)
                        else:
                            self.register(tag, obj)
1238570
def loadFile(self, var, close_on_fail = True):
    
    out = None
    try:
      # First see if it is a full path or directly links from the current
      # working directory
      out = np.load(var)
      if self.Verbose: print("Loading "+var+" from numpy binary")
    except:
      try:
        out = np.loadtxt(var)
        if self.Verbose: print("Loading "+var+" ASCII")
      except:
        # Then see if it is relative to the location of the configuration file
        try:
          out = load(self.inpath + var)
          if self.Verbose: print("Loading "+var+" from numpy binary")
        except:
          try:
            out = np.loadtxt(self.inpath + var)
            if self.Verbose: print("Loading "+var+" ASCII")
          # If failure
          except:
            if close_on_fail:
              print("Cannot find "+var+" file")
              print(""+var+" path = " + var)
              print("Looked relative to model python files.")
              print("Also looked relative to configuration file path,")
              print("  ", self.inpath)
              print("Exiting.")
              sys.exit()
            else:
              pass
    return out
505150
def _import(module, cls):
    
    global Scanner

    try:
        cls = str(cls)
        mod = __import__(str(module), globals(), locals(), [cls], 1)
        Scanner = getattr(mod, cls)
    except ImportError:
        pass
397667
def load_from_module(self, module):
        ''''''
        benchmarks = []
        for name in dir(module):
            obj = getattr(module, name)
            if (inspect.isclass(obj) and issubclass(obj, Benchmark)
                    and obj != Benchmark):
                benchmarks.append(obj)
        return benchmarks
601611
def import_module_from_file(full_path_to_module):
    
    if inspect.ismodule(full_path_to_module):
        return full_path_to_module

    module = None

    try:

        # Get module name and path from full path
        module_dir, module_file = os.path.split(full_path_to_module)
        module_name, module_ext = os.path.splitext(module_file)

        # Get module "spec" from filename
        spec = spec_from_file_location(module_name, full_path_to_module)

        module = spec.loader.load_module()

    except Exception as ec:
        # Simple error printing
        # Insert "sophisticated" stuff here
        print(ec)

    finally:
        return module
499452
def _load(module, globals_dict=None, symb_list=None):
    
    if globals_dict is None:
        globals_dict = six.moves.builtins.__dict__
    try:
        mod = importlib.import_module(module)
        if '__all__' in mod.__dict__:
            # import listed symbols
            for name in mod.__dict__['__all__']:
                if symb_list is not None:
                    symb_list.append(name)
                globals_dict[name] = mod.__dict__[name]
        else:
            # only import non-private symbols
            for name, sym in six.iteritems(mod.__dict__):
                if _validate_local(name):
                    if symb_list is not None:
                        symb_list.append(name)
                    globals_dict[name] = sym
    except Exception:
        log_interactive.error("Loading module %s", module, exc_info=True)
189238
def _load_module(self, name: YangIdentifier,
                     rev: RevisionDate) -> Statement:
        """"""
        for d in self.module_search_path:
            run = 0
            while run < 2:
                fn = f"{d}/{name}"
                if rev and run == 0:
                    fn += "@" + rev
                fn += ".yang"
                try:
                    with open(fn, encoding='utf-8') as infile:
                        res = ModuleParser(infile.read(), name, rev).parse()
                except (FileNotFoundError, PermissionError, ModuleContentMismatch):
                    run += 1
                    continue
                return res
        raise ModuleNotFound(name, rev)
493179
def load(file_or_path):
    
    # This is the pickling pain when changing _src -> src
    import sys
    import inspect
    sys.modules['GPy.kern._src'] = kern.src
    for name, module in inspect.getmembers(kern.src):
        if not name.startswith('_'):
            sys.modules['GPy.kern._src.{}'.format(name)] = module
    sys.modules['GPy.inference.optimization'] = inference.optimization
    import paramz
    return paramz.load(file_or_path)
261676
def load_module(self, path, changed_time, parser=None):
        """"""
        if settings.use_filesystem_cache == False:
            return None
        
        try:
            pickle_changed_time = self._index[path]
        except KeyError:
            return None

        if (changed_time is not None and
            pickle_changed_time < changed_time):
            # the pickle file is outdated
            return None

        target_path = self._get_hashed_path(path)
        with open(target_path, 'rb') as f:
            try:
                gc.disable()
                cache_module = pickle.load(f)
                if parser is not None:
                    for mod in cache_module:
                        mod.unpickle(parser)
            finally:
                gc.enable()

        debug.dbg('pickle loaded: %s', path)
        return cache_module
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
360510
def load(filename: str, format: str = None):
    """"""

    path = Path(filename).resolve()

    with path.open() as file:
        data = file.read()

    if format is None:
        loader, error_class = _load_autodetect, InvalidMofileFormat
    else:
        try:
            loader, error_class = formats[format]
        except KeyError:
            raise InvalidMofileFormat(f'Unknown file format: {format}')

    try:
        config = loader(data)
    except error_class as e:
        raise InvalidMofileFormat(f'Unable to load task file: {e}')

    return Project(config, path.parent)
151965
def load(cls, filename, dir=None, main=False, **kwargs):
        
        name = main and "__main__" or Path(filename).stem
        loader = cls(name, str(filename), **kwargs)
        module = module_from_spec(FileModuleSpec(name, loader, origin=loader.path))
        cwd = str(Path(loader.path).parent)
        try:
            with ExitStack() as stack:
                sys.path.append(cwd)
                loader.name != "__main__" and stack.enter_context(_installed_safely(module))
                loader.exec_module(module)
        finally:
            sys.path.pop()

        return module
1339492
def __load(self):
        
        parts = self.__class_name.split('.')
        module_name = ".".join(parts[:-1])
        module = __import__(module_name)
        modules = []
        for comp in parts[1:]:
            module = getattr(module, comp)
            modules.append(module)

        self.__module = modules[-2]
805548
def load_module(self, name):
        
        _verbose_message('namespace module loaded with path {!r}', self.path)

        # Adjusting code from LoaderBasics
        if name in sys.modules:
            mod = sys.modules[name]
            self.exec_module(mod)
            # In this case we do not want to remove the module in case of error
            # Ref : https://docs.python.org/3/reference/import.html#loaders
        else:
            try:
                # Building custom spec and loading as in _LoaderBasics...
                spec = ModuleSpec(name, self, origin='namespace', is_package=True)
                spec.submodule_search_locations = self.path

                # this will call create_module and also initialize the module properly (like for py3)
                mod = module_from_spec(spec)

                # as per https://docs.python.org/3/reference/import.html#loaders
                assert mod.__name__ in sys.modules

                self.exec_module(mod)
                # We don't ensure that the import-related module attributes get
                # set in the sys.modules replacement case.  Such modules are on
                # their own.
            except:
                # as per https://docs.python.org/3/reference/import.html#loaders
                if name in sys.modules:
                    del sys.modules[name]
                raise

        return sys.modules[name]
85058
function _loadFile(filename){
  var module = require(filename);
  delete require.cache[require.resolve(filename)];
  return module;
}
211172
def _load_from_module(module):
    
    settings = OrderedDict()

    for key in dir(module):
        if key.isupper():
            settings[key] = getattr(module, key)
    return settings