コード例 #1
0
ファイル: repology-dump.py プロジェクト: alerque/repology
    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)
                    ))
コード例 #2
0
def PackagesetToBestByRepo(packages):
    state_by_repo = {}

    for package in PackagesetSortByVersion(packages):
        if package.repo not in state_by_repo or (
                VersionClass.IsIgnored(
                    state_by_repo[package.repo].versionclass)
                and not VersionClass.IsIgnored(package.versionclass)):
            state_by_repo[package.repo] = package

    return state_by_repo
コード例 #3
0
def api_v1_package_to_json(package):
    output = {
        field: getattr(package, field)
        for field in (
            'repo',
            'subrepo',
            'name',
            'version',
            'origversion',
            #'status',
            'maintainers',
            #'category',
            #'comment',
            #'homepage',
            'licenses',
            'downloads') if getattr(package, field)
    }

    # XXX: these tweaks should be implemented in core
    if package.homepage:
        output['www'] = [package.homepage]
    if package.comment:
        output['summary'] = package.comment
    if package.category:
        output['categories'] = [package.category]

    output['status'] = VersionClass.ToString(package.versionclass)

    return output
コード例 #4
0
ファイル: repology-dump.py プロジェクト: Ikke/repology
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
コード例 #5
0
ファイル: packageproc.py プロジェクト: smersh2/repology
def packageset_to_best_by_repo(packages):
    state_by_repo = {}

    for package in packageset_sort_by_version(packages):
        if package.repo not in state_by_repo or (VersionClass.IsIgnored(state_by_repo[package.repo].versionclass) and not VersionClass.IsIgnored(package.versionclass)):
            state_by_repo[package.repo] = package

    return state_by_repo
コード例 #6
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
コード例 #7
0
ファイル: repology-dump.py プロジェクト: AlmAck/repology
def format_package_field(key, value):
    if key == 'versionclass':
        return VersionClass.ToString(value)
    if isinstance(value, dict):
        return str({k: v for k, v in sorted(value.items())})
    return str(value)