public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/scripts/
Date: Mon, 23 Oct 2023 17:35:44 +0000 (UTC)	[thread overview]
Message-ID: <1698080610.590658425abffe0253602adc30f7c22172f92b13.arthurzam@gentoo> (raw)

commit:     590658425abffe0253602adc30f7c22172f92b13
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 23 17:03:30 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> 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 <arthurzam <AT> 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())


             reply	other threads:[~2023-10-23 17:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-23 17:35 Arthur Zamarin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-01-20 17:17 [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/scripts/ Arthur Zamarin
2025-01-18 17:21 Arthur Zamarin
2025-01-15 20:02 Arthur Zamarin
2025-01-15 20:02 Arthur Zamarin
2023-11-24 15:17 Arthur Zamarin
2023-11-24 15:17 Arthur Zamarin
2022-12-22  7:11 Arthur Zamarin
2022-11-12 10:51 Arthur Zamarin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1698080610.590658425abffe0253602adc30f7c22172f92b13.arthurzam@gentoo \
    --to=arthurzam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox