def catalog_list(catalog, distro=None, print_versions=True, **kwargs):

    index = catalog.get_index()

    def pretty_without_versions(result):
        return "%s" % (result['bundle_name'])

    def pretty_with_versions(result):
        distros = index.distributions_for_bundle_by_version(result['bundle_name'])
        versions = index.versions_for_bundle(result['bundle_name'])
        version_strings = list()
        for version in versions:
            version_string = str(version)
            if distros.get(version) is not None:
                distro_string = "(%s)" % (", ".join(sorted(distros.get(version))))
                version_string += '=' + distro_string
                version_strings.append(version_string)

        final_version_string = "[%s]" % (", ".join(version_strings))
        return "%s %s" % (result['bundle_name'], final_version_string)

    pretty = pretty_with_versions if print_versions else pretty_without_versions

    def results():
        bundle_names = sorted(index.bundle_names())
        for bundle_name in bundle_names:
            d = dict()
            if distro and distro not in index.distributions_for_bundle(bundle_name):
                continue
            d['bundle_name'] = bundle_name
            d['versions'] = index.versions_for_bundle(bundle_name)
            d['distros'] = index.distributions_for_bundle(bundle_name)
            yield DictResult(d, pretty=pretty)

    return ResultSet(results)
dataset/ETHPy150Open mindsnacks/Zinc/src/zinc/client.py/catalog_list/original