Esempio n. 1
0
def badge_version_only_for_repo(repo, name):
    if repo not in repometadata.all_names():
        flask.abort(404)

    packages = get_db().get_metapackage_packages(
        name, fields=['repo', 'version', 'versionclass'])
    best_pkg_by_repo = PackagesetToBestByRepo(packages)

    if repo not in best_pkg_by_repo:
        return (
            flask.render_template('badge-tiny-string.svg', string='-'),
            # XXX: it's more correct to return 404 with content
            # here, but some browsers (e.g. Firefox) won't display
            # the image in that case
            {
                'Content-type': 'image/svg+xml'
            })

    return (flask.render_template(
        'badge-tiny-version-only.svg',
        repo=repo,
        version=best_pkg_by_repo[repo].version,
        versionclass=best_pkg_by_repo[repo].versionclass,
    ), {
        'Content-type': 'image/svg+xml'
    })
Esempio n. 2
0
    def package_processor(packageset):
        FillPackagesetVersions(packageset)

        if not PackagesetCheckFilters(packageset, *filters):
            return

        if options.dump == 'packages':
            for package in packageset:
                print(
                    options.field_separator.join(
                        [
                            VersionClass.ToString(package.versionclass) if field == 'versionclass' else str(getattr(package, field))
                            for field in options.fields
                        ]
                    )
                )
        if options.dump == 'summaries':
            print(packageset[0].effname)
            best_pkg_by_repo = PackagesetToBestByRepo(packageset)
            for reponame in repomgr.GetNames(options.reponames):
                if reponame in best_pkg_by_repo:
                    print('  {}: {} ({})'.format(
                        reponame,
                        best_pkg_by_repo[reponame].version,
                        VersionClass.ToString(best_pkg_by_repo[reponame].versionclass)
                    ))
Esempio n. 3
0
def badge_vertical_allrepos(name):
    packages = get_db().get_metapackage_packages(name, fields=['repo', 'version', 'versionclass'])
    best_pkg_by_repo = PackagesetToBestByRepo(packages)

    header = flask.request.args.to_dict().get('header', 'Packaging status')

    entries = [
        {
            'repo': repometadata[reponame],
            'package': best_pkg_by_repo[reponame]
        } for reponame in repometadata.active_names() if reponame in best_pkg_by_repo
    ]

    if not entries:
        header = 'No known packages'

    return (
        flask.render_template(
            'badge-vertical.svg',
            entries=entries,
            name=name,
            header=header
        ),
        {'Content-type': 'image/svg+xml'}
    )
Esempio n. 4
0
def main():
    options = parse_arguments()

    logger = StderrLogger()
    if options.logfile:
        logger = FileLogger(options.logfile)

    if options.fields == 'all':
        options.fields = sorted(Package().__dict__.keys())
    else:
        options.fields = options.fields.split(',')

    # Set up filters
    filters = []
    if options.maintainer:
        filters.append(MaintainerFilter(options.maintainer))
    if options.category:
        filters.append(CategoryFilter(options.maintainer))
    if options.more_repos is not None or options.less_repos is not None:
        filters.append(FamilyCountFilter(more=options.more_repos, less=options.less_repos))
    if options.in_repository:
        filters.append(InRepoFilter(options.in_repository))
    if options.not_in_repository:
        filters.append(NotInRepoFilter(options.not_in_repository))
    if options.outdated_in_repository:
        filters.append(OutdatedInRepoFilter(options.not_in_repository))
    if not options.no_shadow:
        filters.append(ShadowFilter())

    repomgr = RepositoryManager(options.repos_dir)
    repoproc = RepositoryProcessor(repomgr, options.statedir)

    logger.Log('dumping...')
    for packageset in repoproc.StreamDeserializeMulti(reponames=options.reponames):
        FillPackagesetVersions(packageset)

        if not PackagesetCheckFilters(packageset, *filters):
            continue

        if options.dump == 'packages':
            for package in packageset:
                print(
                    options.field_separator.join(
                        (
                            format_package_field(field, getattr(package, field)) for field in options.fields
                        )
                    )
                )
        if options.dump == 'summaries':
            print(packageset[0].effname)
            best_pkg_by_repo = PackagesetToBestByRepo(packageset)
            for reponame in repomgr.GetNames(options.reponames):
                if reponame in best_pkg_by_repo:
                    print('  {}: {} ({})'.format(
                        reponame,
                        best_pkg_by_repo[reponame].version,
                        VersionClass.ToString(best_pkg_by_repo[reponame].versionclass)
                    ))

    return 0
Esempio n. 5
0
def badge_version_for_repo(repo, name):
    if repo not in repometadata.all_names():
        flask.abort(404)

    packages = get_db().get_metapackage_packages(
        name, fields=['repo', 'version', 'versionclass'])
    best_pkg_by_repo = PackagesetToBestByRepo(packages)

    if repo not in best_pkg_by_repo:
        # XXX: display this as normal "pill" badge with correct repository name
        return (
            flask.render_template('badge-tiny-string.svg',
                                  string='No package'),
            # XXX: it's more correct to return 404 with content
            # here, but some browsers (e.g. Firefox) won't display
            # the image in that case
            {
                'Content-type': 'image/svg+xml'
            })

    minversion = flask.request.args.to_dict().get('minversion')
    unsatisfying = version_compare(best_pkg_by_repo[repo].version,
                                   minversion) < 0 if minversion else False

    return (flask.render_template(
        'badge-tiny-version.svg',
        repo=repo,
        version=best_pkg_by_repo[repo].version,
        versionclass=best_pkg_by_repo[repo].versionclass,
        unsatisfying=unsatisfying,
    ), {
        'Content-type': 'image/svg+xml'
    })
Esempio n. 6
0
def badge_version_only_for_repo(repo, name):
    best_pkg_by_repo = PackagesetToBestByRepo(get_db().GetMetapackage(name))

    if repo not in best_pkg_by_repo:
        flask.abort(404)

    return (flask.render_template(
        'badge-tiny-version-only.svg',
        repo=repo,
        version=best_pkg_by_repo[repo].version,
        versionclass=best_pkg_by_repo[repo].versionclass,
    ), {
        'Content-type': 'image/svg+xml'
    })
Esempio n. 7
0
def badge_vertical_allrepos(name):
    best_pkg_by_repo = PackagesetToBestByRepo(get_db().GetMetapackage(name))

    entries = [{
        'repo': repometadata[reponame],
        'package': best_pkg_by_repo[reponame]
    } for reponame in reponames
               if reponame in repometadata and reponame in best_pkg_by_repo]

    return (flask.render_template('badge-vertical.svg',
                                  entries=entries,
                                  name=name), {
                                      'Content-type': 'image/svg+xml'
                                  })
Esempio n. 8
0
def badge_vertical_allrepos(name):
    packages = get_db().get_metapackage_packages(
        name, fields=['repo', 'version', 'versionclass'])
    best_pkg_by_repo = PackagesetToBestByRepo(packages)

    entries = [{
        'repo': repometadata[reponame],
        'package': best_pkg_by_repo[reponame]
    } for reponame in reponames
               if reponame in repometadata and reponame in best_pkg_by_repo]

    return (flask.render_template('badge-vertical.svg',
                                  entries=entries,
                                  name=name), {
                                      'Content-type': 'image/svg+xml'
                                  })
Esempio n. 9
0
def badge_version_only_for_repo(repo, name):
    packages = get_db().get_metapackage_packages(
        name, fields=['repo', 'version', 'versionclass'])
    best_pkg_by_repo = PackagesetToBestByRepo(packages)

    if repo not in best_pkg_by_repo:
        return (flask.render_template('badge-tiny-string.svg',
                                      string='-'), 404, {
                                          'Content-type': 'image/svg+xml'
                                      })

    return (flask.render_template(
        'badge-tiny-version-only.svg',
        repo=repo,
        version=best_pkg_by_repo[repo].version,
        versionclass=best_pkg_by_repo[repo].versionclass,
    ), {
        'Content-type': 'image/svg+xml'
    })
Esempio n. 10
0
def main():
    options = parse_arguments()

    logger = StderrLogger()
    if options.logfile:
        logger = FileLogger(options.logfile)

    if options.fields == 'all':
        options.fields = sorted(Package().__dict__.keys())
    else:
        options.fields = options.fields.split(',')

    repomgr = RepositoryManager(options.repos_dir)
    repoproc = RepositoryProcessor(repomgr, options.statedir,
                                   options.parseddir)

    logger.Log('dumping...')
    for packageset in repoproc.iter_parsed(reponames=options.reponames):
        FillPackagesetVersions(packageset)

        if not options.all and packageset_is_shadow_only(packageset):
            continue

        if options.dump == 'packages':
            for package in packageset:
                print(
                    options.field_separator.join(
                        (format_package_field(field, getattr(package, field))
                         for field in options.fields)))
        if options.dump == 'summaries':
            print(packageset[0].effname)
            best_pkg_by_repo = PackagesetToBestByRepo(packageset)
            for reponame in repomgr.GetNames(options.reponames):
                if reponame in best_pkg_by_repo:
                    print('  {}: {} ({})'.format(
                        reponame, best_pkg_by_repo[reponame].version,
                        VersionClass.ToString(
                            best_pkg_by_repo[reponame].versionclass)))

    return 0
Esempio n. 11
0
def badge_version_for_repo(repo, name):
    packages = get_db().get_metapackage_packages(name, fields=['repo', 'version', 'versionclass'])
    best_pkg_by_repo = PackagesetToBestByRepo(packages)

    if repo not in best_pkg_by_repo:
        # XXX: display this as normal "pill" badge with correct repository name
        return (
            flask.render_template('badge-tiny-string.svg', string='No package'),
            # XXX: it's more correct to return 404 with content
            # here, but some browsers (e.g. Firefox) won't display
            # the image in that case
            {'Content-type': 'image/svg+xml'}
        )

    return (
        flask.render_template(
            'badge-tiny-version.svg',
            repo=repo,
            version=best_pkg_by_repo[repo].version,
            versionclass=best_pkg_by_repo[repo].versionclass,
        ),
        {'Content-type': 'image/svg+xml'}
    )