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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 39879138334 for ; Fri, 3 Jan 2020 04:31:28 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 64384E0AD9; Fri, 3 Jan 2020 04:31:27 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4947BE0AD5 for ; Fri, 3 Jan 2020 04:31:27 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4A66D34DE5E for ; Fri, 3 Jan 2020 04:31:26 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 147CA7C for ; Fri, 3 Jan 2020 04:31:24 +0000 (UTC) From: "Matt Turner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Turner" Message-ID: <1578000294.059b8857c2114f2ca0cec3ec5408d28ecc38ee62.mattst88@gentoo> Subject: [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/imlate/ X-VCS-Repository: proj/gentoolkit X-VCS-Files: pym/gentoolkit/imlate/imlate.py X-VCS-Directories: pym/gentoolkit/imlate/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: 059b8857c2114f2ca0cec3ec5408d28ecc38ee62 X-VCS-Branch: master Date: Fri, 3 Jan 2020 04:31:24 +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: ea8bb275-9500-4845-9efe-e4c2a3d7d7fd X-Archives-Hash: c5b64bbde209ce874848ec3eff5839c2 commit: 059b8857c2114f2ca0cec3ec5408d28ecc38ee62 Author: Matt Turner gentoo org> AuthorDate: Thu Jan 2 17:50:31 2020 +0000 Commit: Matt Turner gentoo 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 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()