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 (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id CC8F3158089 for ; Mon, 23 Oct 2023 17:35:48 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1F5C52BC01D; Mon, 23 Oct 2023 17:35:48 +0000 (UTC) Received: from smtp.gentoo.org (dev.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 D92B92BC01D for ; Mon, 23 Oct 2023 17:35:47 +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)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3056B335CB4 for ; Mon, 23 Oct 2023 17:35:47 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 4F68212B9 for ; Mon, 23 Oct 2023 17:35:44 +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: <1698080610.590658425abffe0253602adc30f7c22172f92b13.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/pmaint.py X-VCS-Directories: src/pkgcore/scripts/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 590658425abffe0253602adc30f7c22172f92b13 X-VCS-Branch: master Date: Mon, 23 Oct 2023 17:35:44 +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: db472476-3456-44ad-b8cb-afb2b74f6341 X-Archives-Hash: 0df53fb98567273e1abf1bb4fa52f78a commit: 590658425abffe0253602adc30f7c22172f92b13 Author: Arthur Zamarin gentoo org> AuthorDate: Mon Oct 23 17:03:30 2023 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Mon Oct 23 17:03:30 2023 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=59065842 pmaint eclass: add better invocation with output filename format Signed-off-by: Arthur Zamarin gentoo.org> src/pkgcore/scripts/pmaint.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/pkgcore/scripts/pmaint.py b/src/pkgcore/scripts/pmaint.py index 008de533f..c148454a7 100644 --- a/src/pkgcore/scripts/pmaint.py +++ b/src/pkgcore/scripts/pmaint.py @@ -496,6 +496,19 @@ eclass_opts = eclass.add_argument_group("subcommand options") eclass_opts.add_argument( "--dir", dest="output_dir", type=arghparse.create_dir, help="output directory" ) +eclass_opts.add_argument( + "-o", + "--output", + dest="output_format", + default="{eclass}.eclass.{format}", + help="output file name format", + docs=""" + Output file name format. Defaults to ``{eclass}.eclass.{format}``. You + can use ``{eclass}`` and ``{format}`` placeholders to customize the + output file name. The filename can have path separator, for example: + ``{eclass}/{eclass}.eclass.{format}``. + """, +) eclass_opts.add_argument( "-f", "--format", @@ -541,9 +554,16 @@ def _eclass_main(options, out, err): for path in options.eclasses: try: - with open( - pjoin(options.output_dir, f"{os.path.basename(path)}.{ext}"), "wt" - ) as f: + filename = pjoin( + options.output_dir, + options.output_format.format( + eclass=os.path.basename(path).removesuffix(".eclass"), + format=ext, + ), + ) + out.write("Compiling: ", path) + os.makedirs(os.path.dirname(filename), exist_ok=True) + with open(filename, "wt") as f: obj = EclassDoc(path, sourced=True) convert_func = getattr(obj, f"to_{options.format}") f.write(convert_func())