コード例 #1
0
def project_information(name: str) -> Any:
    metapackage = get_db().get_metapackage(name)

    if not metapackage or metapackage['num_repos'] == 0:
        return handle_nonexisting_project(name, metapackage)

    packages = sorted(
        (PackageDataDetailed(**item)
         for item in get_db().get_metapackage_packages(name, detailed=True)),
        key=lambda package: package.repo + package.visiblename + package.
        version)

    information: Dict[str, Any] = {}

    def append_info(infokey: str, infoval: str,
                    package: PackageDataDetailed) -> None:
        if infokey not in information:
            information[infokey] = {}

        if infoval not in information[infokey]:
            information[infokey][infoval] = set()

        information[infokey][infoval].add(package.family)

    for package in packages:
        append_info('names', package.visiblename, package)
        append_info('versions', package.version, package)
        append_info('repos', package.repo, package)

        if package.comment:
            append_info('summaries', package.comment, package)
        for maintainer in package.maintainers:
            append_info('maintainers', maintainer, package)
        if package.category:
            append_info('categories', package.category, package)
        if package.homepage:
            append_info('homepages', package.homepage, package)
        for download in package.downloads:
            append_info('downloads', download, package)
        for license_ in package.licenses:
            append_info('licenses', license_, package)

    if 'repos' in information:
        # preserve repos order
        information['repos'] = [(reponame, information['repos'][reponame])
                                for reponame in repometadata.active_names()
                                if reponame in information['repos']]

    versions = packageset_aggregate_by_version(
        packages, {PackageStatus.LEGACY: PackageStatus.OUTDATED})

    return flask.render_template(
        'project-information.html',
        name=name,
        metapackage=metapackage,
        information=information,
        versions=versions,
        link_statuses=get_db().get_metapackage_link_statuses(name))
コード例 #2
0
ファイル: project.py プロジェクト: AlmAck/repology
def project_information(name):
    packages = get_db().get_metapackage_packages(name)
    packages = sorted(
        packages,
        key=lambda package: package.repo + package.name + package.version)

    information = {}

    def append_info(infokey, infoval, package):
        if infokey not in information:
            information[infokey] = {}

        if infoval not in information[infokey]:
            information[infokey][infoval] = set()

        information[infokey][infoval].add(package.family)

    for package in packages:
        append_info('names', package.name, package)
        append_info('versions', package.version, package)
        append_info('repos', package.repo, package)

        if package.comment:
            append_info('summaries', package.comment, package)
        for maintainer in package.maintainers:
            append_info('maintainers', maintainer, package)
        if package.category:
            append_info('categories', package.category, package)
        if package.homepage:
            append_info('homepages', package.homepage, package)
        for download in package.downloads:
            append_info('downloads', download, package)
        for license_ in package.licenses:
            append_info('licenses', license_, package)

    if 'repos' in information:
        # preserve repos order
        information['repos'] = [(reponame, information['repos'][reponame])
                                for reponame in repometadata.active_names()
                                if reponame in information['repos']]

    versions = packageset_aggregate_by_version(
        packages, {VersionClass.legacy: VersionClass.outdated})

    return flask.render_template(
        'project-information.html',
        information=information,
        versions=versions,
        metapackage=get_db().get_metapackage(name),
        name=name,
        link_statuses=get_db().get_metapackage_link_statuses(name))
コード例 #3
0
def project_information(name: str) -> Response:
    metapackage = get_db().get_metapackage(name)

    if not metapackage or metapackage['num_repos'] == 0:
        return handle_nonexisting_project(name, metapackage)

    packages = sorted(
        (PackageDataDetailed(**item)
         for item in get_db().get_metapackage_packages(name, detailed=True)),
        key=lambda package:
        (package.repo, package.visiblename, package.version))

    information: Dict[str, Any] = {}

    def append_info(infokey: str, infoval: Any,
                    package: PackageDataDetailed) -> None:
        if infokey not in information:
            information[infokey] = {}

        if infoval not in information[infokey]:
            information[infokey][infoval] = set()

        information[infokey][infoval].add(package.family)

    for package in packages:
        append_info('names', package.projectname_seed, package)
        append_info('versions', package.version, package)
        append_info('repos', package.repo, package)

        if package.comment:
            append_info('summaries', package.comment, package)
        if package.maintainers is not None:
            for maintainer in package.maintainers:
                append_info('maintainers', maintainer, package)
        if package.category:
            append_info('categories', package.category, package)
        if package.licenses is not None:
            for license_ in package.licenses:
                append_info('licenses', license_, package)
        if package.links is not None:
            maybe_raw_links = defaultdict(list)
            for link_type, link_id in package.links:
                if link_type in [
                        LinkType.UPSTREAM_HOMEPAGE, LinkType.PROJECT_HOMEPAGE
                ]:
                    append_info('homepages', link_id, package)
                elif link_type in [
                        LinkType.UPSTREAM_DOWNLOAD, LinkType.PROJECT_DOWNLOAD
                ]:
                    append_info('downloads', link_id, package)
                elif link_type == LinkType.UPSTREAM_ISSUE_TRACKER:
                    append_info('issues', link_id, package)
                elif link_type == LinkType.UPSTREAM_REPOSITORY:
                    append_info('repositories', link_id, package)
                elif link_type == LinkType.UPSTREAM_DOCUMENTATION:
                    append_info('documentation', link_id, package)
                elif link_type == LinkType.PACKAGE_HOMEPAGE:
                    append_info('packages', link_id, package)
                elif link_type == LinkType.PACKAGE_RECIPE:
                    maybe_raw_links['recipes'].append(link_id)
                elif link_type == LinkType.PACKAGE_RECIPE_RAW:
                    maybe_raw_links['recipes_raw'].append(link_id)
                elif link_type == LinkType.PACKAGE_PATCH:
                    maybe_raw_links['patches'].append(link_id)
                elif link_type == LinkType.PACKAGE_PATCH_RAW:
                    maybe_raw_links['patches_raw'].append(link_id)
                elif link_type == LinkType.PACKAGE_BUILD_LOG:
                    maybe_raw_links['buildlogs'].append(link_id)
                elif link_type == LinkType.PACKAGE_BUILD_LOG_RAW:
                    maybe_raw_links['buildlogs_raw'].append(link_id)

            # for links which may have both human-readlabe and raw flavors, we
            # prefer human-readable ones here
            for key in ['recipes', 'patches', 'buildlogs']:
                if key in maybe_raw_links:
                    for link_id in maybe_raw_links[key]:
                        append_info(key, link_id, package)
                elif key + '_raw' in maybe_raw_links:
                    for link_id in maybe_raw_links[key + '_raw']:
                        append_info(key, link_id, package)

    if 'repos' in information:
        # preserve repos order
        information['repos'] = [(reponame, information['repos'][reponame])
                                for reponame in repometadata.active_names()
                                if reponame in information['repos']]

    versions = packageset_aggregate_by_version(
        packages, {PackageStatus.LEGACY: PackageStatus.OUTDATED})

    links = get_db().get_project_links(name)

    for key in [
            'homepages', 'downloads', 'issues', 'repositories', 'patches',
            'buildlogs', 'documentation', 'recipes'
    ]:
        if key in information:
            information[key] = sorted(
                information[key].items(),
                key=lambda l: links[l[0]]['url'].lower()  # type: ignore
            )

    return flask.render_template('project-information.html',
                                 name=name,
                                 metapackage=metapackage,
                                 information=information,
                                 versions=versions,
                                 links=links)