Use find_packages code to find modules. Can find LOTS of modules.
        :return:
518062
def via_find_packages(self):  # type: () -> List[str]
        
        packages = []  # type: List[str]
        source = self.setup_py_source()
        if not source:
            return packages
        for row in source.split("\n"):
            if "find_packages" in row:
                logger.debug(row)
                if "find_packages()" in row:
                    packages = find_packages()
                else:
                    try:
                        value = row.split("(")[1].split(")")[0]
                        packages = find_packages(ast.literal_eval(value))
                        logger.debug(unicode(packages))
                    except:
                        logger.debug(source)
                        # raise

        return packages
721903
def find_packages(name, pkg_dir):
    """"""
    for c in (FileSystemPackageBuilder, ZipPackageBuilder, ExcelPackageBuilder):

        package_path, cache_path = c.make_package_path(pkg_dir, name)

        if package_path.exists():

            yield c.type_code, package_path, cache_path
1074670
def find_subdirectories(package):
    
    try:
        subdirectories = os.walk(package_to_path(package)).next()[1]
    except StopIteration:
        subdirectories = []
    return subdirectories
1074353
def get_package_modules(packagename):
    
    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, packagename)
            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__), packagename)
        modnames = [x[:-3] for x in get_importable_files(dirname)]
    for modname in modnames:
        try:
            name ="..%s.%s" % (packagename, modname)
            yield importlib.import_module(name, __name__)
        except ImportError as msg:
            print("WARN: could not load module %s: %s" % (modname, msg))
1145435
def find_package(name, installed, package=False):
    '''
    '''
    if package:
        name = name.lower()
        tests = (
            lambda x: x.user and name == x.name.lower(),
            lambda x: x.local and name == x.name.lower(),
            lambda x: name == x.name.lower(),
        )
    else:
        tests = (
            lambda x: x.user and name in x.import_names,
            lambda x: x.local and name in x.import_names,
            lambda x: name in x.import_names,
        )

    for t in tests:
        try:
            found = list(filter(t, installed))
            if found and not found[0].is_scan:
                return found[0]
        except StopIteration:
            pass
    return None
542660
def get_packages():
    

    packages = find_packages(exclude=['tests'])
    packages.append('')
    packages.append('js')
    packages.append(LOCALES_DIRECTORY)

    for directory in os.listdir(LOCALES_DIRECTORY):
        packages.append(LOCALES_DIRECTORY + '.' + directory)
    return packages
1347918
def find(self, package, **kwargs):
        
        if not exists(package):
            return None
        name, path = None, None
        enforce_init = kwargs.pop('enforce_init', True)
        if isdir(package):
            if isfile(join(package, '__init__.py')) or not enforce_init:
                name, path = basename(package), package
        elif isfile(package) and package.endswith('.py'):
            name, path = splitext(basename(package))[0], package
        if name and path:
            return PackageSpec(name, path)
        return None
1339217
def find_module(self, fullname, path=None):
        
        # path points to the top-level package path if any
        # and we can only import sub-modules/-packages
        if path is None:
            return
        if fullname.startswith(self.module_prefix):
            return self
        else:
            return None
795258
def find_plugins():
     
    plugin_dir = os.path.dirname(os.path.realpath(__file__))
    plugin_dir = os.path.join(plugin_dir, "plugins")
    plugin_files = [x[:-3] for x in os.listdir(plugin_dir) if x.endswith(".py")]
    sys.path.insert(0, plugin_dir)
    for plugin in plugin_files:
        __import__(plugin)
1331430
def find_top_level_modules_by_dunder_init(self):  # type: () -> List[str]
        
        # TODO: use package_dirs
        packaged_dirs = ""
        try:
            # Right now only returns 1st.
            packaged_dirs = self.extract_package_dir()
        except:
            pass
        likely_src_folders = [".", "src", "lib"]
        if packaged_dirs and packaged_dirs not in likely_src_folders:
            likely_src_folders.append(packaged_dirs)

        candidates = []
        for likely_src in likely_src_folders:
            if not os.path.isdir(likely_src):
                continue
            folders = [
                f
                for f in os.listdir(likely_src)
                if os.path.isdir(os.path.join(likely_src, f))
            ]

            for folder in folders:
                if os.path.isfile(os.path.join(likely_src, folder, "__init__.py")):
                    # dunder_source = self.file_opener.read_file(folder + "/__init__.py")
                    candidates.append(folder)

        return list(set([x for x in candidates if x]))
441787
def find_module(slug)
      modules.find { |m| m.slug.to_s == slug.to_s }
    end
1044174
def _build_package_finder(
        self,
        options,               # type: Values
        session,               # type: PipSession
        platform=None,         # type: Optional[str]
        python_versions=None,  # type: Optional[List[str]]
        abi=None,              # type: Optional[str]
        implementation=None    # type: Optional[str]
    ):
        # type: (...) -> PackageFinder
        
        index_urls = [options.index_url] + options.extra_index_urls
        if options.no_index:
            logger.debug(
                'Ignoring indexes: %s',
                ','.join(redact_password_from_url(url) for url in index_urls),
            )
            index_urls = []

        return PackageFinder(
            find_links=options.find_links,
            format_control=options.format_control,
            index_urls=index_urls,
            trusted_hosts=options.trusted_hosts,
            allow_all_prereleases=options.pre,
            session=session,
            platform=platform,
            versions=python_versions,
            abi=abi,
            implementation=implementation,
            prefer_binary=options.prefer_binary,
        )
198884
def _getModules(self):
        
        modules = {}
        modulesPath = os.path.join("application", "module")
        moduleList = os.listdir(modulesPath)

        for moduleName in moduleList:
            modulePath = os.path.join(modulesPath, moduleName, "module.py")
            if not os.path.isfile(modulePath):
                continue

            # importing module
            moduleSpec = importlib.util.spec_from_file_location(
                moduleName,
                modulePath
            )
            module = importlib.util.module_from_spec(moduleSpec)
            moduleSpec.loader.exec_module(module)

            # initializing module
            moduleInstance = module.Module(self)
            modules[moduleName] = moduleInstance

        return modules
1106094
def find_modules(self, requested_names):
        
        found_modules = set()
        for requested_name in requested_names:
            is_instance = " " in requested_name

            for module_name, module in self.py3_wrapper.output_modules.items():
                if module["type"] == "py3status":
                    name = module["module"].module_nice_name
                else:
                    name = module["module"].module_name
                if is_instance:
                    if requested_name == name:
                        found_modules.add(module_name)
                else:
                    if requested_name == name.split(" ")[0]:
                        found_modules.add(module_name)

        if self.debug:
            self.py3_wrapper.log("found %s" % found_modules)
        return found_modules
1076860
def _build_package_finder(self, options, index_urls, session):
        
        return PackageFinder(
            find_links=options.find_links,
            index_urls=index_urls,
            allow_all_prereleases=options.pre,
            trusted_hosts=options.trusted_hosts,
            session=session,
        )
1277983
def find_module(self, fullname):
        

        spec = self.find_spec(fullname)
        if spec is None:
            return None

        # We need to handle the namespace case here for python2
        if spec.loader is None and len(spec.submodule_search_locations):
            spec.loader = NamespaceLoader2(spec.name, spec.submodule_search_locations)

        return spec.loader
90048
def find(self, pkg, flag):
        
        print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
            self.cyan, ", ".join(pkg), self.endc))
        Msg().template(78)
        print("| {0}  {1}{2}{3}".format("Repository", "Package", " " * 54,
                                        "Size"))
        Msg().template(78)
        for repo in _meta_.repositories:
            PACKAGES_TXT = PackageManager(pkg).list_lib(repo)
            packages, sizes = PackageManager(pkg).list_greps(repo, PACKAGES_TXT)
            for find, size in zip(packages, sizes):
                for p in pkg:
                    if "--case-ins" in flag:
                        self.p_cache = p.lower()
                        self.find_cache = find.lower()
                    else:
                        self.p_cache = p
                        self.find_cache = find
                    if self.p_cache in self.find_cache:
                        if self.cache != repo:
                            self.count_repo += 1
                        self.cache = repo
                        self.count_pkg += 1
                        ver = self.sbo_version(repo, find)
                        print("  {0}{1}{2}{3}{4} {5}{6:>11}".format(
                            self.cyan, repo, self.endc,
                            " " * (12 - len(repo)),
                            find + ver, " " * (53 - len(find + ver)),
                            size))
        print("\nFound summary")
        print("=" * 79)
        print("{0}Total found {1} packages in {2} repositories."
              "{3}\n".format(self.grey, self.count_pkg,
                             self.count_repo, self.endc))