public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Matt Turner" <mattst88@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/imlate/
Date: Fri,  3 Jan 2020 04:31:24 +0000 (UTC)	[thread overview]
Message-ID: <1578000294.059b8857c2114f2ca0cec3ec5408d28ecc38ee62.mattst88@gentoo> (raw)

commit:     059b8857c2114f2ca0cec3ec5408d28ecc38ee62
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 17:50:31 2020 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 21:24:54 2020 +0000
URL:        https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=059b8857

imlate: Dynamically calculate column width in report

Also print categories on the line with the package name for much simpler
consumption by external tools.

Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 pym/gentoolkit/imlate/imlate.py | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/pym/gentoolkit/imlate/imlate.py b/pym/gentoolkit/imlate/imlate.py
index 86d1a7e..40e2914 100755
--- a/pym/gentoolkit/imlate/imlate.py
+++ b/pym/gentoolkit/imlate/imlate.py
@@ -67,11 +67,18 @@ def _fill( width, line, fill = " " ):
 # create a hopefully pretty result
 def show_result( conf, pkgs ):
 	# X - len(colX) = space to fill
-	col1 = 40
-	col2 = 20
+	col1 = -1
+	col2 = -1
+	for cat in pkgs:
+		for pkg in pkgs[cat]:
+			col1 = max(col1, len(("%s/%s" % (cat, pkg))))
+			col2 = max(col2, len(pkgs[cat][pkg][1]))
+	col1 += 1
+	col2 += 1
 
 	_header = "%s candidates for 'gentoo' on '%s'"
-	_helper = "category/package[:SLOT]                 our version         best version"
+	_helper = "%s%s%s" % (_fill(col1, "category/package[:SLOT])"),
+						  _fill(col2, "our version"), "best version")
 	_cand = ""
 	header = ""
 
@@ -102,11 +109,10 @@ def show_result( conf, pkgs ):
 	print(_fill( len( _helper ), "", "-" ), file=out)
 
 	for cat in sorted( pkgs.keys() ):
-		print("%s/" % cat, file=out)
 		for pkg in sorted( pkgs[cat].keys() ):
-			print("%s%s%s" % ( _fill( col1, ( "  %s" % pkg ) ),
-									_fill( col2, pkgs[cat][pkg][1] ),
-									pkgs[cat][pkg][0] ), file=out)
+			print("%s%s%s" % (_fill(col1, ("%s/%s" % (cat, pkg))),
+							  _fill(col2, pkgs[cat][pkg][1]),
+							  pkgs[cat][pkg][0] ), file=out)
 
 	if conf["FILE"] != "stdout":
 		out.close()


             reply	other threads:[~2020-01-03  4:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-03  4:31 Matt Turner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-03-16 19:02 [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/imlate/ Matt Turner
2017-03-22 12:51 Brian Dolbec

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=1578000294.059b8857c2114f2ca0cec3ec5408d28ecc38ee62.mattst88@gentoo \
    --to=mattst88@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