From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D203815813A for ; Wed, 15 Jan 2025 20:02:34 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EF268E07D7; Wed, 15 Jan 2025 20:02:33 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D5F4CE07D8 for ; Wed, 15 Jan 2025 20:02:33 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1A853343B07 for ; Wed, 15 Jan 2025 20:02:33 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 4C6C3213B for ; Wed, 15 Jan 2025 20:02:31 +0000 (UTC) From: "Arthur Zamarin" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arthur Zamarin" Message-ID: <1736971316.6a98a8395bf825870fcb0514c61e8b26b97d2fe1.arthurzam@gentoo> Subject: [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/scripts/ X-VCS-Repository: proj/pkgcore/pkgcore X-VCS-Files: src/pkgcore/scripts/pquery.py X-VCS-Directories: src/pkgcore/scripts/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 6a98a8395bf825870fcb0514c61e8b26b97d2fe1 X-VCS-Branch: master Date: Wed, 15 Jan 2025 20:02:31 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 3130fb3e-abf7-4807-966d-9c53f70fc21e X-Archives-Hash: c732604b8337e273dcf173e5e4aad7c5 commit: 6a98a8395bf825870fcb0514c61e8b26b97d2fe1 Author: Arthur Zamarin gentoo org> AuthorDate: Wed Jan 15 20:01:56 2025 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Wed Jan 15 20:01:56 2025 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=6a98a839 pquery: support input from stdin when "-" is passed as an argument Resolves: https://github.com/pkgcore/pkgcore/issues/226 Signed-off-by: Arthur Zamarin gentoo.org> src/pkgcore/scripts/pquery.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/pkgcore/scripts/pquery.py b/src/pkgcore/scripts/pquery.py index 7211441f..6ab6a79f 100644 --- a/src/pkgcore/scripts/pquery.py +++ b/src/pkgcore/scripts/pquery.py @@ -15,8 +15,9 @@ running them on source repos makes no sense. import errno import os -from functools import partial +import sys import typing +from functools import partial from snakeoil.cli import arghparse from snakeoil.formatters import decorate_forced_wrapping @@ -705,9 +706,17 @@ def bind_add_query(*args, **kwds): type=None, help="extended atom matching of pkgs", ) -def matches_finalize(targets, namespace): +def matches_finalize(targets: list[str], namespace): repos = multiplex.tree(*namespace.repos) + if "-" in targets: + if not sys.stdin.isatty(): + idx = targets.index("-") + in_targets = [x.strip() for x in sys.stdin.readlines()] + targets = targets[:idx] + in_targets + targets[idx + 1 :] + else: + argparser.error("reading from stdin is only valid when piping data in") + # If current working dir is in a repo, build a path restriction; otherwise # match everything. if not targets: