Beispiel #1
0
def api_v1_metapackages(bound=None):
    filterinfo = MetapackagesFilterInfo()
    filterinfo.ParseFlaskArgs()

    request = filterinfo.GetRequest()
    request.Bound(bound)

    packages = get_db().GetMetapackages(request,
                                        limit=config['METAPACKAGES_PER_PAGE'])

    metapackages = PackagesToMetapackages(packages)

    metapackages = {
        metapackage_name:
        [api_v1_package_to_json(package) for package in packageset]
        for metapackage_name, packageset in metapackages.items()
    }

    return (json.dumps(metapackages), {'Content-type': 'application/json'})
Beispiel #2
0
def metapackages(bound=None):
    # process search
    filterinfo = MetapackagesFilterInfo()
    filterinfo.ParseFlaskArgs()

    request = filterinfo.GetRequest()
    request.Bound(bound)

    # get packages
    def get_packages(request):
        metapackages = get_db().query_metapackages(
            **request.__dict__,
            limit=config['METAPACKAGES_PER_PAGE'],
        )

        packages = get_db().get_metapackages_packages(
            list(metapackages.keys()),
            fields=['repo', 'family', 'effname', 'version', 'versionclass', 'maintainers', 'flags']
        )

        return metapackages, packages

    metapackages, packages = get_packages(request)

    # on empty result, fallback to show first, last set of results
    if not packages:
        request = filterinfo.GetRequest()
        if bound and bound.startswith('..'):
            request.NameTo(None)
        metapackages, packages = get_packages(request)

    firstname, lastname = get_packages_name_range(packages)

    metapackagedata = metapackages_to_summary_items(packages_to_metapackages(packages), filterinfo.GetRepo(), filterinfo.GetMaintainer())

    return flask.render_template(
        'metapackages.html',
        firstname=firstname,
        lastname=lastname,
        search=filterinfo.GetDict(),
        advanced=filterinfo.IsAdvanced(),
        metapackages=metapackages,
        metapackagedata=metapackagedata,
        repo=filterinfo.GetRepo(),
        maintainer=filterinfo.GetMaintainer()
    )
Beispiel #3
0
def api_v1_metapackages(bound=None):
    filterinfo = MetapackagesFilterInfo()
    filterinfo.ParseFlaskArgs()

    request = filterinfo.GetRequest()
    request.Bound(bound)

    metapackages = get_db().query_metapackages(
        **request.__dict__, limit=config['METAPACKAGES_PER_PAGE'])

    packages = get_db().get_metapackages_packages(list(metapackages.keys()))

    metapackages = packages_to_metapackages(packages)

    metapackages = {
        metapackage_name:
        [api_v1_package_to_json(package) for package in packageset]
        for metapackage_name, packageset in metapackages.items()
    }

    return (dump_json(metapackages), {'Content-type': 'application/json'})
Beispiel #4
0
def api_v1_projects(bound: Optional[str] = None) -> Any:
    filterinfo = MetapackagesFilterInfo()
    filterinfo.parse_flask_args()

    request = filterinfo.get_request()
    request.set_bound(bound)

    metapackages = get_db().query_metapackages(
        **request.__dict__, limit=config['METAPACKAGES_PER_PAGE'])

    packages = get_db().get_metapackages_packages(list(metapackages.keys()))

    metapackages = packages_to_metapackages(packages)

    metapackages = {
        metapackage_name:
        [api_v1_package_to_json(package) for package in packageset]
        for metapackage_name, packageset in metapackages.items()
    }

    return (dump_json(metapackages), {'Content-type': 'application/json'})
Beispiel #5
0
def projects(bound: Optional[str] = None) -> Response:
    # process search
    filterinfo = MetapackagesFilterInfo()
    filterinfo.parse_flask_args()

    request = filterinfo.get_request()
    request.set_bound(bound)

    # get packages
    def get_packages(
        request: MetapackageRequest
    ) -> Tuple[Dict[str, Dict[str, Any]], List[PackageDataSummarizable]]:
        metapackages = get_db().query_metapackages(
            **request.__dict__,
            limit=config['METAPACKAGES_PER_PAGE'],
        )

        packages = [
            PackageDataSummarizable(**item)
            for item in get_db().get_metapackages_packages(
                list(metapackages.keys()), summarizable=True)
        ]

        return metapackages, packages

    metapackages, packages = get_packages(request)

    # on empty result, fallback to show first, last set of results
    if not packages:
        request = filterinfo.get_request()
        if bound and bound.startswith('..'):
            request.require_name_to(None)
        metapackages, packages = get_packages(request)

    firstname, lastname = get_packages_name_range(packages)

    metapackagedata = packages_to_summary_items(packages,
                                                filterinfo.get_repo(),
                                                filterinfo.get_maintainer())

    return flask.render_template('projects.html',
                                 firstname=firstname,
                                 lastname=lastname,
                                 search=filterinfo.get_dict(),
                                 advanced=filterinfo.is_advanced(),
                                 metapackages=metapackages,
                                 metapackagedata=metapackagedata,
                                 repo=filterinfo.get_repo(),
                                 maintainer=filterinfo.get_maintainer())
Beispiel #6
0
def metapackages(bound=None):
    # process search
    filterinfo = MetapackagesFilterInfo()
    filterinfo.ParseFlaskArgs()

    request = filterinfo.GetRequest()
    request.Bound(bound)

    # get packages
    packages = get_db().GetMetapackages(request,
                                        limit=config['METAPACKAGES_PER_PAGE'])

    # on empty result, fallback to show first, last set of results
    if not packages:
        request = filterinfo.GetRequest()
        if bound and bound.startswith('..'):
            request.NameTo(None)
        packages = get_db().GetMetapackages(
            request, limit=config['METAPACKAGES_PER_PAGE'])

    firstname, lastname = get_packages_name_range(packages)

    metapackagedata = metapackages_to_summary_items(
        PackagesToMetapackages(packages), filterinfo.GetRepo(),
        filterinfo.GetMaintainer())

    return flask.render_template('metapackages.html',
                                 firstname=firstname,
                                 lastname=lastname,
                                 search=filterinfo.GetDict(),
                                 advanced=filterinfo.IsAdvanced(),
                                 metapackagedata=metapackagedata,
                                 repo=filterinfo.GetRepo(),
                                 maintainer=filterinfo.GetMaintainer())