Get list of installed modules.
14507
def get_base_modules():
    "  "

    return sorted(filter(
                  lambda x: op.isdir(op.join(MOD_DIR, x)),
                  listdir(MOD_DIR)))
926896
def get_enabled_modules():
  
  enabled = []
  directory_contents = os.listdir(MODULES_FOLDER_PATH)
  for fname in get_installed_modules():
    if not fname+'.disabled' in directory_contents:
      enabled.append(fname)
  return enabled
623643
def _find_modules(src):
    """"""
    directors = 0
    mnames = []
    try:
        matches = _reModule.findall(open(src).read())
    except IOError:
        # If the file's not yet generated, guess the module name from the file stem
        matches = []
        mnames.append(os.path.splitext(os.path.basename(src))[0])

    for m in matches:
        mnames.append(m[2])
        directors = directors or m[0].find('directors') >= 0
    return mnames, directors
270020
def list_dependencies(self, module, result):
        """"""
        if result is None:
            result = {}
        #We will try at least once to load each module that we don't have
        if module not in self.modules:
            self.load_dependency(module, True, True, False)

        if module in self.modules and module not in result:
            result[module] = self.modules[module].filepath
            for depend in self.modules[module].dependencies:
                name = depend.split(".")[0].lower()
                if name not in result:
                    self.list_dependencies(name, result)

        return result
576592
def get_modules(pkg_name, module_filter = None):
    
    path = app_path(pkg_name)
    #py_filter = lambda f: all((fnmatch(f, "*.py"), not f.startswith("__"), module_filter and module_filter(f) or True))
    py_filter = lambda f: all((fnmatch(f, "*.pyc") or fnmatch(f, "*.py"), not f.startswith("__"), module_filter and module_filter(f) or True))
    names = [splitext(n)[0] for n in os.listdir(path) if py_filter(n)]
    return [__import__("{0}.{1}".format(pkg_name, n)).__dict__[n] for n in names]
409229
def get_mod_paths(mod_name, out_dir):
    """"""
    paths = []
    try:
        mod = get_loader(mod_name)
        source = Path(mod.path)
        if source.name.endswith(".py"):
            source_rel = Path(*mod_name.split("."))
            if source.name == "__init__.py":
                source_rel = source_rel.joinpath("__init__.py")
            destination = Path(out_dir, source_rel.with_suffix(".pyi"))
            paths.append((source, destination))
    except Exception as e:
        _logger.debug(e)
        _logger.warning("cannot handle module, skipping: %s", mod_name)
    return paths
954066
def collect_plugins(self, modules=None):
        
        if modules is None:
            modules = self.get_loaded_modules()
        else:
            modules = util.return_list(modules)

        plugins = []
        for module in modules:
            module_plugins = [(item[1], item[0])
                              for item
                              in inspect.getmembers(module)
                              if item[1] and item[0] != '__builtins__']
            module_plugins, names = zip(*module_plugins)

            module_plugins = self._filter_modules(module_plugins, names)
            plugins.extend(module_plugins)
        return plugins
1299716
protected function getModuleInfo(): array
    {
        if ($this->moduleInfo === null) {
            $this->moduleInfo = $this->package()->getExtra()['module'] ?? [];
        }

        return $this->moduleInfo;
    }
446870
def get_modules(root_path):
    """"""
    for dir_path, dir_names, file_names in os.walk(root_path):
        assert dir_path[:len(root_path)] == root_path
        subdir_path = dir_path[len(root_path):]
        package_parts = list(filter(lambda x: x, subdir_path.split('/')))
        for name in file_names:
            if name.endswith('.py'):
                path = os.path.join(dir_path, name)
                pkgpath = '.'.join(package_parts)
                modpath = (pkgpath if name == '__init__.py' else
                           '.'.join(package_parts + [name[:-3]]))
                try:
                    node = ast.parse(open(path).read())
                except SyntaxError:
                    print('ERROR: Invalid syntax in %s' % path, file=sys.stderr)
                else:
                    yield (pkgpath, modpath, path, node)
649604
def listModules(self):
        """"""
        modules = list(self.modules.items())
        modules.sort()
        return [module for name, module in modules]
33598
public static function modules($status = 'installed') {
        switch ($status) {
            case 'uninstalled':
                $modules = array_filter(self::$modules, function (Module $m) {
                    return !$m->installed;
                });
                break;
            case 'installed':
                $modules = array_filter(self::$modules, function (Module $m) {
                    return $m->installed;
                });
                break;
            case 'enabled':
                $modules = array_filter(self::$modules, function (Module $m) {
                    return $m->enabled;
                });
                break;
            case 'disabled':
                $modules = array_filter(self::$modules, function (Module $m) {
                    return !$m->enabled && $m->installed;
                });
                break;
            case 'upgradable':
                $modules = array_filter(self::$modules, function (Module $m) {
                    return $m->upgradable && $m->installed;
                });
                break;
            default:
                $modules = self::$modules;
                break;
        }

        return $modules;
    }
1232186
def collect_loaded_packages() -> List[Tuple[str, str]]:
    
    dists = get_installed_distributions()
    get_dist_files = DistFilesFinder()
    file_table = {}
    for dist in dists:
        for file in get_dist_files(dist):
            file_table[file] = dist
    used_dists = set()
    # we greedily load all values to a list to avoid weird
    # "dictionary changed size during iteration" errors
    for module in list(sys.modules.values()):
        try:
            dist = file_table[module.__file__]
        except (AttributeError, KeyError):
            continue
        used_dists.add(dist)
    return sorted((dist.project_name, dist.version) for dist in used_dists)
1263319
def check(self):
        """"""
        return programs.is_module_installed(self.modname,
                                            self.required_version,
                                            self.installed_version)
310587
def find_third_party_modules ():
    """"""
    parent = os.path.dirname(os.path.dirname(__file__))
    third_party = os.path.join(parent, "third_party")
    if os.path.isdir(third_party):
        sys.path.append(os.path.join(third_party, "dnspython"))
1188279
def python_modules():
        
        imported = {}
        results = {"builtins": sys.builtin_module_names, "imported": imported}
        for module_name, module_ in sys.modules.items():
            if module_name not in sys.builtin_module_names:
                try:
                    imported[module_name] = inspect.getfile(module_)
                except TypeError:
                    imported[
                        module_name
                    ] = "<no file information :: {0}>".format(repr(module_))

        return results
532172
public function getInstalledModules()
    {
        $modules = $this->modules;

        if ($this->rootModule) {
            unset($modules[$this->rootModule->getName()]);
        }

        return $modules;
    }
572896
public List<String> getUptodateModules() {

        if (m_uptodateModules == null) {
            m_uptodateModules = new ArrayList<String>();
            m_modulesToUpdate = new ArrayList<String>();
            Map<String, CmsModuleVersion> installedModules = getInstalledModules();
            Map<String, CmsModule> availableModules = getAvailableModules();
            Iterator<Map.Entry<String, CmsModule>> itMods = availableModules.entrySet().iterator();
            while (itMods.hasNext()) {
                Map.Entry<String, CmsModule> entry = itMods.next();
                String name = entry.getKey();
                CmsModuleVersion instVer = installedModules.get(name);
                CmsModuleVersion availVer = entry.getValue().getVersion();
                boolean uptodate = (!UPDATE_ALL_MODULES) && ((instVer != null) && (instVer.compareTo(availVer) >= 0));
                if (uptodate) {
                    m_uptodateModules.add(name);
                } else {
                    m_modulesToUpdate.add(name);
                }
                if (LOG.isDebugEnabled()) {
                    LOG.debug(
                        name + " --- installed: " + instVer + " available: " + availVer + " --- uptodate: " + uptodate);
                }
            }
        }
        return m_uptodateModules;
    }