Пример #1
0
def main(options, out, err):
    continued = False
    for token, restriction in options.targets:
        for pkgs in pkgutils.groupby_pkg(options.repo.itermatch(restriction, sorter=sorted)):
            if options.collapse:
                out.write(' '.join(_collapse_arches(options, pkgs)))
            else:
                arches = sorted(options.arches.intersection(options.native_arches))
                if options.prefix:
                    arches += sorted(options.arches.intersection(options.prefix_arches))
                headers = [''] + arches + ['eapi', 'slot', 'repo']
                if continued:
                    out.write()
                if not options.pkg_dir:
                    pkgs = list(pkgs)
                    out.write(f'keywords for {pkgs[0].unversioned_atom}:')
                data = _render_rows(options, pkgs, arches)
                table = tabulate(
                    data, headers=headers, tablefmt=options.format,
                    disable_numparse=True)
                out.write(table)
            continued = True

    if not continued:
        err.write(f"{options.prog}: no matches for {token!r}")
        return 1
Пример #2
0
def main(options, out, err):
    """Run a query."""

    try:
        mangle_values(options, err)
    except _Fail:
        return -1

    if options.debug:
        for repo in options.repos:
            out.write('repo: %r' % (repo, ))
        out.write('restrict: %r' % (options.query, ))
        out.write()

    if options.query is None:
        return 0
    for repo in options.repos:
        try:
            for pkgs in pkgutils.groupby_pkg(
                    repo.itermatch(options.query, sorter=sorted)):
                pkgs = list(pkgs)
                if options.noversion:
                    print_packages_noversion(options, out, err, pkgs)
                elif options.min or options.max:
                    if options.min:
                        print_package(options, out, err, min(pkgs))
                    if options.max:
                        print_package(options, out, err, max(pkgs))
                else:
                    for pkg in pkgs:
                        print_package(options, out, err, pkg)
                        if options.earlyout:
                            break
                if options.earlyout:
                    break

        except KeyboardInterrupt:
            raise
        except Exception as e:
            if isinstance(e, IOError) and e.errno == errno.EPIPE:
                # swallow it; receiving end shutdown early.
                return
            err.write('caught an exception!')
            err.write('repo: %r' % (repo, ))
            err.write('restrict: %r' % (options.query, ))
            raise
Пример #3
0
def main(options, out, err):
    """Run a query."""

    try:
        mangle_values(options, err)
    except _Fail:
        return -1

    if options.debug:
        for repo in options.repos:
            out.write('repo: %r' % (repo,))
        out.write('restrict: %r' % (options.query,))
        out.write()

    if options.query is None:
        return 0
    for repo in options.repos:
        try:
            for pkgs in pkgutils.groupby_pkg(
                repo.itermatch(options.query, sorter=sorted)):
                pkgs = list(pkgs)
                if options.noversion:
                    print_packages_noversion(options, out, err, pkgs)
                elif options.min or options.max:
                    if options.min:
                        print_package(options, out, err, min(pkgs))
                    if options.max:
                        print_package(options, out, err, max(pkgs))
                else:
                    for pkg in pkgs:
                        print_package(options, out, err, pkg)
                        if options.earlyout:
                            break
                if options.earlyout:
                    break

        except KeyboardInterrupt:
            raise
        except Exception, e:
            if isinstance(e, IOError) and e.errno == errno.EPIPE:
                # swallow it; receiving end shutdown early.
                return
            err.write('caught an exception!')
            err.write('repo: %r' % (repo,))
            err.write('restrict: %r' % (options.query,))
            raise
Пример #4
0
def main(options, out, err):
    """Run a query."""
    if options.debug:
        for repo in options.repos:
            out.write(f'repo: {repo.repo_id}')
        out.write(f'restrict: {options.query}')
        out.write()

    if options.query is None:
        return 0
    for repo in options.repos:
        try:
            for pkgs in pkgutils.groupby_pkg(
                    repo.itermatch(options.query, sorter=sorted)):
                pkgs = list(pkgs)
                if options.noversion:
                    print_packages_noversion(options, out, err, pkgs)
                elif options.min or options.max:
                    if options.min:
                        print_package(options, out, err, min(pkgs))
                    if options.max:
                        print_package(options, out, err, max(pkgs))
                else:
                    for pkg in pkgs:
                        print_package(options, out, err, pkg)
                        if options.first:
                            break
                if options.first:
                    break

        except KeyboardInterrupt:
            raise
        except Exception as e:
            if isinstance(e, IOError) and e.errno == errno.EPIPE:
                # swallow it; receiving end shutdown early.
                return
            # force a newline for error msg or traceback output
            err.write()
            raise
Пример #5
0
def main(options, out, err):
    """Run a query."""
    if options.debug:
        for repo in options.repos:
            out.write(f'repo: {repo.repo_id}')
        out.write(f'restrict: {options.query}')
        out.write()

    if options.query is None:
        return 0
    for repo in options.repos:
        try:
            for pkgs in pkgutils.groupby_pkg(repo.itermatch(options.query, sorter=sorted)):
                pkgs = list(pkgs)
                if options.noversion:
                    print_packages_noversion(options, out, err, pkgs)
                elif options.min or options.max:
                    if options.min:
                        print_package(options, out, err, min(pkgs))
                    if options.max:
                        print_package(options, out, err, max(pkgs))
                else:
                    for pkg in pkgs:
                        print_package(options, out, err, pkg)
                        if options.first:
                            break
                if options.first:
                    break

        except KeyboardInterrupt:
            raise
        except Exception as e:
            if isinstance(e, IOError) and e.errno == errno.EPIPE:
                # swallow it; receiving end shutdown early.
                return
            # force a newline for error msg or traceback output
            err.write()
            raise
Пример #6
0
def main(options, out, err):
    continued = False
    for token, restriction in options.targets:
        for pkgs in pkgutils.groupby_pkg(options.repo.itermatch(restriction, sorter=sorted)):
            if options.collapse:
                out.write(' '.join(_collapse_arches(options, pkgs)))
            else:
                arches = sorted(options.arches.intersection(options.native_arches))
                if options.prefix:
                    arches += sorted(options.arches.intersection(options.prefix_arches))
                headers = [''] + arches + ['eapi', 'slot', 'repo']
                if continued:
                    out.write()
                if not options.pkg_dir:
                    pkgs = list(pkgs)
                    out.write(f'keywords for {pkgs[0].unversioned_atom}:')
                data = _render_rows(options, pkgs, arches)
                table = tabulate(data, headers=headers, tablefmt=options.format)
                out.write(table)
            continued = True

    if not continued:
        err.write(f"{options.prog}: no matches for {token!r}")
        return 1