Returns a list of file-based module loaders.
    Each item is a tuple (loader, suffixes).
3093
def get_supported_file_loaders_2(force=False):
    

    if force or (2, 7) <= sys.version_info < (3, 4):  # valid until which py3 version ?

        import imp

        loaders = []
        for suffix, mode, type in imp.get_suffixes():
            if type == imp.PY_SOURCE:
                loaders.append((SourceFileLoader2, [suffix]))
            else:
                loaders.append((ImpFileLoader2, [suffix]))
        return loaders

    elif sys.version_info >= (3, 4):  # valid from which py3 version ?

        from importlib.machinery import (
            SOURCE_SUFFIXES, SourceFileLoader,
            BYTECODE_SUFFIXES, SourcelessFileLoader,
            EXTENSION_SUFFIXES, ExtensionFileLoader,
        )

        # This is already defined in importlib._bootstrap_external
        # but is not exposed.
        extensions = ExtensionFileLoader, EXTENSION_SUFFIXES
        source = SourceFileLoader, SOURCE_SUFFIXES
        bytecode = SourcelessFileLoader, BYTECODE_SUFFIXES
        return [extensions, source, bytecode]
820593
def files(
            self):
        
        relatedFilesResultsList = []
        relatedFilesResultsList[:] = [dict(l)
                                      for l in self.relatedFilesResultsList]
        return relatedFilesResultsList
853195
def load_plugins():
    
    loader = _PluginLoader()

    for pkg in PLUGIN_PACKAGES:
        loader.load_plugins(pkg)

    return loader.plugins
745633
def file_list(load):
    '''
    
    '''
    if 'env' in load:
        # "env" is not supported; Use "saltenv".
        load.pop('env')

    if load['saltenv'] not in envs():
        return []
    mountpoint = salt.utils.url.strip_proto(__opts__['minionfs_mountpoint'])
    prefix = load.get('prefix', '').strip('/')
    if mountpoint and prefix.startswith(mountpoint + os.path.sep):
        prefix = prefix[len(mountpoint + os.path.sep):]

    minions_cache_dir = os.path.join(__opts__['cachedir'], 'minions')
    minion_dirs = os.listdir(minions_cache_dir)

    # If the prefix is not an empty string, then get the minion id from it. The
    # minion ID will be the part before the first slash, so if there is no
    # slash, this is an invalid path.
    if prefix:
        tgt_minion, _, prefix = prefix.partition('/')
        if not prefix:
            # No minion ID in path
            return []
        # Reassign minion_dirs so we don't unnecessarily walk every minion's
        # pushed files
        if tgt_minion not in minion_dirs:
            log.warning(
                'No files found in minionfs cache for minion ID \'%s\'',
                tgt_minion
            )
            return []
        minion_dirs = [tgt_minion]

    ret = []
    for minion in minion_dirs:
        if not _is_exposed(minion):
            continue
        minion_files_dir = os.path.join(minions_cache_dir, minion, 'files')
        if not os.path.isdir(minion_files_dir):
            log.debug(
                'minionfs: could not find files directory under %s!',
                os.path.join(minions_cache_dir, minion)
            )
            continue
        walk_dir = os.path.join(minion_files_dir, prefix)
        # Do not follow links for security reasons
        for root, _, files in salt.utils.path.os_walk(walk_dir, followlinks=False):
            for fname in files:
                # Ignore links for security reasons
                if os.path.islink(os.path.join(root, fname)):
                    continue
                relpath = os.path.relpath(
                    os.path.join(root, fname), minion_files_dir
                )
                if relpath.startswith('../'):
                    continue
                rel_fn = os.path.join(mountpoint, minion, relpath)
                if not salt.fileserver.is_file_ignored(__opts__, rel_fn):
                    ret.append(rel_fn)
    return ret
732192
def get_modules_list(self, pattern=None):
        '''
        
        '''
        if pattern and '*' not in pattern:
            pattern = '*{0}*'.format(pattern)
        modules = []
        for m_name, m_path in self._modules_map.items():
            m_path = m_path.split('.')[0]
            m_name = '.'.join([elm for elm in m_path.split(os.path.sep) if elm])
            if pattern and fnmatch.fnmatch(m_name, pattern) or not pattern:
                modules.append(m_name)
        return sorted(modules)
205874
def iter_modules(self, module=None, filename=None, source=None, excludes=None):
    

    if excludes is None:
      excludes = self.excludes

    if not filename:
      if not module:
        raise ValueError('need either module or filename parameter')
      module = self.find_module(module)
      if not module.filename or module.type == 'native':
        return
    else:
      module = ModuleInfo('__main__', filename, ModuleInfo.SRC)

    seen = set()
    stack = collections.deque()

    for imp in get_imports(module.filename, source):
      stack.appendleft((module.join_import_from(imp.name), [module.name]))

    yield module
    while stack:
      import_name, imported_from = stack.pop()
      if import_name in seen:
        continue
      seen.add(import_name)
      if check_module_exclude(import_name, excludes):
        continue

      module = self.find_module(import_name)
      module.imported_from[:] = imported_from
      yield module

      if module.type == ModuleInfo.SRC:
        imported_from = [module.name] + imported_from
        for imp in get_imports(module.filename):
          stack.append((module.join_import_from(imp.name), imported_from))
221675
def get_modules(folder):
    
    if is_frozen():
        # find modules in library.zip filename
        zipname = os.path.dirname(os.path.dirname(__file__))
        parentmodule = os.path.basename(os.path.dirname(__file__))
        with zipfile.ZipFile(zipname, 'r') as f:
            prefix = "%s/%s/" % (parentmodule, folder)
            modnames = [os.path.splitext(n[len(prefix):])[0]
              for n in f.namelist()
              if n.startswith(prefix) and "__init__" not in n]
    else:
        dirname = os.path.join(os.path.dirname(__file__), folder)
        modnames = get_importable_modules(dirname)
    for modname in modnames:
        try:
            name ="..%s.%s" % (folder, modname)
            yield importlib.import_module(name, __name__)
        except ImportError as msg:
            out.error("could not load module %s: %s" % (modname, msg))
427044
function list() {
    var adapters = [];
    _.each(adapterConfig, function(config, adapter) {
        var modulePath = adapterModulePath(adapter, config);
        var version, installPath, moduleName;

        var isBuiltin = BUILTIN_ADAPTERS.indexOf(adapter) !== -1;
        var loaded = true;
        if (isBuiltin) {
            version = juttleVersion;
            installPath = Module._resolveFilename(modulePath, module);
            moduleName = '(builtin)';
        } else {
            try {
                var packagePath = path.join(modulePath, 'package');
                var pkg = require(packagePath);
                installPath = path.dirname(Module._resolveFilename(packagePath, module));
                version = pkg.version || '(unknown)';
                moduleName = pkg.name;
            } catch (err) {
                installPath = '(unable to load adapter)';
                version = '(unknown)';
                moduleName = '(unknown)';
                loaded = false;
            }
        }
        adapters.push({adapter: adapter, builtin: isBuiltin, module: moduleName, version: version, path: installPath, loaded: loaded});
    });
    return adapters;
}
754398
def get_python_files(files):
        """"""
        python_files = []
        for file_name in files:
            if file_name.endswith(".py"):
                python_files.append(file_name)

        return python_files
88853
def load_files(file_finder)
      if file_finder.options.fetch(:files).empty?
        file_finder.list(*options[:extensions])
      else
        file_finder.options.fetch(:files) { [] }
      end
    end
1110497
def load(self, *modules):
        
        for module in modules:
            if isinstance(module, six.string_types):
                try:
                    module = get_object(module)
                except Exception as e:
                    self.errors[module] = e
                    continue
            self.modules[module.__package__] = module
            for (loader, module_name, is_pkg) in pkgutil.walk_packages(
                module.__path__
            ):
                full_name = "{}.{}".format(_package(module), module_name)
                try:
                    self.modules[full_name] = get_object(full_name)
                    if is_pkg:
                        self.load(self.modules[full_name])
                except Exception as e:
                    self.errors[full_name] = e
1034823
def list_classes(mod_name):
    
    mod = sys.modules[mod_name]
    return [cls.__name__ for cls in mod.__dict__.values()
            if is_mod_class(mod, cls)]
520033
def filenames(self) -> Tuple[str, ...]:
        """"""
        return tuple(sorted(set(itertools.chain(
            *(_.keys() for _ in self.folders.values())))))
616150
def get_plugin_classes(modules):
    """"""
    classes = (_ConnectionPlugin, _ContentPlugin, _ParserPlugin)
    return loader.get_plugins(modules, classes)
497386
def load_each(*loaders):
    
    def _load_each(metadata):
        return merge(
            loader(metadata)
            for loader in loaders
        )
    return _load_each
244014
def _iter_module_files():
    
    # The list call is necessary on Python 3 in case the module
    # dictionary modifies during iteration.
    for module in list(sys.modules.values()):
        if module is None:
            continue
        filename = getattr(module, "__file__", None)
        if filename:
            if os.path.isdir(filename) and os.path.exists(
                os.path.join(filename, "__init__.py")
            ):
                filename = os.path.join(filename, "__init__.py")

            old = None
            while not os.path.isfile(filename):
                old = filename
                filename = os.path.dirname(filename)
                if filename == old:
                    break
            else:
                if filename[-4:] in (".pyc", ".pyo"):
                    filename = filename[:-1]
                yield filename
571473
def get_filelist(run_module_names):
    
    # Prep search patterns
    spatterns = [{},{},{},{},{},{},{}]
    epatterns = [{}, {}]
    ignored_patterns = []
    for key, sps in config.sp.items():
        mod_name = key.split('/', 1)[0]
        if mod_name.lower() not in [m.lower() for m in run_module_names]:
            ignored_patterns.append(key)
            continue
        files[key] = list()
        if not isinstance(sps, list):
            sps = [sps]

        # Warn if we have any unrecognised search pattern keys
        expected_sp_keys = [
            'fn',
            'fn_re',
            'contents',
            'contents_re',
            'num_lines',
            'shared',
            'max_filesize',
            'exclude_fn',
            'exclude_fn_re',
            'exclude_contents',
            'exclude_contents_re'
        ]
        unrecognised_keys = [y for x in sps for y in x.keys() if y not in expected_sp_keys]
        if len(unrecognised_keys) > 0:
            logger.warn("Unrecognised search pattern keys for '{}': {}".format(key, ', '.join(unrecognised_keys)))

        # Split search patterns according to speed of execution.
        if any([x for x in sps if 'contents_re' in x]):
            if any([x for x in sps if 'num_lines' in x]):
                spatterns[4][key] = sps
            elif any([x for x in sps if 'max_filesize' in x]):
                spatterns[5][key] = sps
            else:
                spatterns[6][key] = sps
        elif any([x for x in sps if 'contents' in x]):
            if any([x for x in sps if 'num_lines' in x]):
                spatterns[1][key] = sps
            elif any([x for x in sps if 'max_filesize' in x]):
                spatterns[2][key] = sps
            else:
                spatterns[3][key] = sps
        else:
            spatterns[0][key] = sps

    if len(ignored_patterns) > 0:
        logger.debug("Ignored {} search patterns as didn't match running modules.".format(len(ignored_patterns)))

    def add_file(fn, root):
        """
        Function applied to each file found when walking the analysis
        directories. Runs through all search patterns and returns True
        if a match is found.
        """
        f = {'fn': fn, 'root': root}

        # Check that this is a file and not a pipe or anything weird
        if not os.path.isfile(os.path.join(root, fn)):
            return None

        # Check that we don't want to ignore this file
        i_matches = [n for n in config.fn_ignore_files if fnmatch.fnmatch(fn, n)]
        if len(i_matches) > 0:
            logger.debug("Ignoring file as matched an ignore pattern: {}".format(fn))
            return None

        # Limit search to small files, to avoid 30GB FastQ files etc.
        try:
            f['filesize'] = os.path.getsize(os.path.join(root,fn))
        except (IOError, OSError, ValueError, UnicodeDecodeError):
            logger.debug("Couldn't read file when checking filesize: {}".format(fn))
        else:
            if f['filesize'] > config.log_filesize_limit:
                return False

        # Test file for each search pattern
        for patterns in spatterns:
            for key, sps in patterns.items():
                for sp in sps:
                    if search_file (sp, f):
                        # Check that we shouldn't exclude this file
                        if not exclude_file(sp, f):
                            # Looks good! Remember this file
                            files[key].append(f)
                        # Don't keep searching this file for other modules
                        if not sp.get('shared', False):
                            return
                        # Don't look at other patterns for this module
                        else:
                            break

    # Go through the analysis directories and get file list
    for path in config.analysis_dir:
        if os.path.islink(path) and config.ignore_symlinks:
            continue
        elif os.path.isfile(path):
            searchfiles.append([os.path.basename(path), os.path.dirname(path)])
        elif os.path.isdir(path):
            for root, dirnames, filenames in os.walk(path, followlinks=(not config.ignore_symlinks), topdown=True):
                bname = os.path.basename(root)

                # Skip any sub-directories matching ignore params
                orig_dirnames = dirnames[:]
                for n in config.fn_ignore_dirs:
                    dirnames[:] = [d for d in dirnames if not fnmatch.fnmatch(d, n.rstrip(os.sep))]
                    if len(orig_dirnames) != len(dirnames):
                        removed_dirs = [os.path.join(root, d) for d in set(orig_dirnames).symmetric_difference(set(dirnames))]
                        logger.debug("Ignoring directory as matched fn_ignore_dirs: {}".format(", ".join(removed_dirs)))
                        orig_dirnames = dirnames[:]
                for n in config.fn_ignore_paths:
                    dirnames[:] = [d for d in dirnames if not fnmatch.fnmatch(os.path.join(root, d), n.rstrip(os.sep))]
                    if len(orig_dirnames) != len(dirnames):
                        removed_dirs = [os.path.join(root, d) for d in set(orig_dirnames).symmetric_difference(set(dirnames))]
                        logger.debug("Ignoring directory as matched fn_ignore_paths: {}".format(", ".join(removed_dirs)))

                # Skip *this* directory if matches ignore params
                d_matches = [n for n in config.fn_ignore_dirs if fnmatch.fnmatch(bname, n.rstrip(os.sep))]
                if len(d_matches) > 0:
                    logger.debug("Ignoring directory as matched fn_ignore_dirs: {}".format(bname))
                    continue
                p_matches = [n for n in config.fn_ignore_paths if fnmatch.fnmatch(root, n.rstrip(os.sep))]
                if len(p_matches) > 0:
                    logger.debug("Ignoring directory as matched fn_ignore_paths: {}".format(root))
                    continue
                # Search filenames in this directory
                for fn in filenames:
                    searchfiles.append([fn, root])
    # Search through collected files
    with click.progressbar(searchfiles, label="Searching {} files..".format(len(searchfiles))) as sfiles:
        for sf in sfiles:
            add_file(sf[0], sf[1])