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 261A815813A for ; Wed, 15 Jan 2025 20:02:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F368AE07D8; Wed, 15 Jan 2025 20:02:33 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (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 pigeon.gentoo.org (Postfix) with ESMTPS id CF957E07D7 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 DA8BF343B06 for ; Wed, 15 Jan 2025 20:02:32 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 38E131F9A 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: <1736971198.c4598e95a81b98bba9373b5f91ff53bcac304efa.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/patom.py X-VCS-Directories: src/pkgcore/scripts/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: c4598e95a81b98bba9373b5f91ff53bcac304efa 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: 8eb0e2eb-f5fc-4a19-b9dd-aaec718e67bb X-Archives-Hash: 59006f485d55925c0e1c907092c651c8 commit: c4598e95a81b98bba9373b5f91ff53bcac304efa Author: Arthur Zamarin gentoo org> AuthorDate: Wed Jan 15 19:59:58 2025 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Wed Jan 15 19:59:58 2025 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=c4598e95 patom: 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/patom.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pkgcore/scripts/patom.py b/src/pkgcore/scripts/patom.py index ac7a2ef2..113bd853 100644 --- a/src/pkgcore/scripts/patom.py +++ b/src/pkgcore/scripts/patom.py @@ -1,6 +1,7 @@ """atom parsing utility""" import re +import sys from functools import partial from ..ebuild.atom import atom as atom_cls @@ -90,6 +91,14 @@ def _transform_format(atom: atom_cls, match: re.Match): def main(options, out, err): if options.format: fmt, *atoms = options.format + + if "-" in atoms: + atoms = [atom for atom in atoms if atom != "-"] + if not sys.stdin.isatty(): + atoms += [x.strip() for x in sys.stdin.readlines()] + else: + argparser.error("reading from stdin is only valid when piping data in") + VAR_REGEX = re.compile(r"%\[.+?\]|%\{.+?\}") for value in atoms: try: