Return a list of packages that match regex_name.
773725
def all_pkgs_by_name_regex(self, regex_name, flags=0):
        
        reg = re.compile(regex_name, flags)
        return [pkg for pkg in self.all_pkgs().keys() if reg.match(pkg)]
429356
def get_subpackages(name):
    """"""
    splist = []
    for dirpath, _dirnames, _filenames in os.walk(name):
        if osp.isfile(osp.join(dirpath, '__init__.py')):
            splist.append(".".join(dirpath.split(os.sep)))
    return splist
673288
def find_package_indexes_in_dir(self, simple_dir):
        """"""
        packages = sorted(
            {
                # Filter out all of the "non" normalized names here
                canonicalize_name(x)
                for x in os.listdir(simple_dir)
            }
        )
        # Package indexes must be in directories, so ignore anything else.
        packages = [x for x in packages if os.path.isdir(os.path.join(simple_dir, x))]
        return packages
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
357165
def via_find_packages(self):  # type: () -> List[str]
        
        packages = []  # type: List[str]
        source = self.setup_py_source()
        if not source:
            return packages
        find_package_args = ""
        for row in source.split("\n"):
            if "find_packages" in row:
                logger.debug(row)
                if "find_packages()" in row:
                    packages = find_packages()
                else:
                    try:

                        find_package_args_source = row.split("(")[1].split(")")[0]
                        find_package_args = ast.literal_eval(find_package_args_source)
                        logger.debug(packages)
                    except:
                        logger.debug(source)
                        # raise
        if not find_package_args:
            packages = find_packages()
        else:
            try:
                # signature find(cls, where='.', exclude=(), include=('*',)):
                packages = find_packages(find_package_args)
            except:
                packages = find_packages()

        return packages
1251988
private function getGitRegexMatches($package)
    {
        if (isset($package->repository)) {
            $repository = $package->repository;
        } else {
            return false;
        }

        preg_match(GIT_REGEX, $repository, $matches);

        return $matches;
    }
213404
def get_package_format_names(predicate=None):
    """"""
    return [
        k
        for k, v in six.iteritems(get_package_formats())
        if not predicate or predicate(k, v)
    ]
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
550647
def fetch_digests(self, package_name: str, package_version: str) -> dict:
        """"""
        report = {}

        for source in self._sources:
            try:
                report[source.url] = source.get_package_hashes(package_name, package_version)
            except NotFound as exc:
                _LOGGER.debug(
                    f"Package {package_name} in version {package_version} not "
                    f"found on index {source.name}: {str(exc)}"
                )

        return report
748438
def file_matches_regexps(filename, patterns):
    """"""
    return any(re.match(pat, filename) for pat in patterns)
903920
def get_packaged_files(package_name):
    
    if not os.path.isdir('dist'):
        return []
    return [os.path.join('dist', filename) for filename in os.listdir('dist')]
1117938
def search(pkg_name, **kwargs):
    '''
    
    '''

    pkglist = {}
    pkgin = _check_pkgin()
    if not pkgin:
        return pkglist

    if _supports_regex():
        pkg_name = '^{0}$'.format(pkg_name)

    out = __salt__['cmd.run'](
        [pkgin, 'se', pkg_name],
        output_loglevel='trace'
    )
    for line in out.splitlines():
        if line:
            match = _splitpkg(line.split()[0])
            if match:
                pkglist[match[0]] = match[1]

    return pkglist
601686
def _name_matches(name, matches):
    '''
    
    '''
    for m in matches:
        if name.endswith(m):
            return True
        if name.lower().endswith('_' + m.lower()):
            return True
        if name.lower() == m.lower():
            return True
    return False
1094525
def check_package_data(dist, attr, value):
    """"""
    if isinstance(value, dict):
        for k, v in value.items():
            if not isinstance(k, str):
                break
            try:
                iter(v)
            except TypeError:
                break
        else:
            return
    raise DistutilsSetupError(
        attr + " must be a dictionary mapping package names to lists of "
        "wildcard patterns"
    )
744603
def discover(package, cls_match_func):
    
    matched_classes = set()

    for _, module_name, _ in pkgutil.walk_packages(
            package.__path__,
            prefix=package.__name__ + '.',
    ):
        module = __import__(module_name, fromlist=[str('__trash')], level=0)

        # Check all the classes in that module
        for _, imported_class in inspect.getmembers(module, inspect.isclass):
            # Don't include things that are only there due to a side-effect of
            # importing
            if imported_class.__module__ != module.__name__:
                continue

            if cls_match_func(imported_class):
                matched_classes.add(imported_class)

    return matched_classes
1233915
def get_match_names(match):
    """"""
    names = []
    if "paren" in match:
        (match,) = match
        names += get_match_names(match)
    elif "var" in match:
        (setvar,) = match
        if setvar != wildcard:
            names.append(setvar)
    elif "trailer" in match:
        match, trailers = match[0], match[1:]
        for i in range(0, len(trailers), 2):
            op, arg = trailers[i], trailers[i + 1]
            if op == "as":
                names.append(arg)
        names += get_match_names(match)
    return names
56827
def get_canonical_names(packages):
    """"""
    from .vendor.packaging.utils import canonicalize_name

    if not isinstance(packages, Sequence):
        if not isinstance(packages, six.string_types):
            return packages
        packages = [packages]
    return set([canonicalize_name(pkg) for pkg in packages if pkg])