Package: ftp.debian.org Severity: wishlist The output of dak ls does not look very good currently, as some cells have contents longer than the expected width. The attached patch fixes this issue.
I have tested the patch by applying it to a local copy of ls.py on ries and running it. -- Julian Andres Klode - Debian Developer, Ubuntu Member See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
From 1119f1bd2b724b9ef6362c9b95ca00898b961afb Mon Sep 17 00:00:00 2001 From: Julian Andres Klode <j...@debian.org> Date: Fri, 12 Apr 2013 16:28:47 +0200 Subject: [PATCH] ls: Calculate optimal column sizes If a package name is longer than 10 characters, or a version longer than 13 characters, columns had different widths in different rows. By calculating the maximum column size and using that instead of hard-coded values, we have a nice table again. --- dak/ls.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dak/ls.py b/dak/ls.py index ea51aae..bc9393e 100755 --- a/dak/ls.py +++ b/dak/ls.py @@ -174,6 +174,20 @@ SELECT s.source, s.version, 'source', su.suite_name, c.name, m.name packages = d.keys() packages.sort() + + # Calculate optimal column sizes + sizes = [10, 13, 10] + for pkg in packages: + versions = d[pkg].keys() + for version in versions: + suites = d[pkg][version].keys() + for suite in suites: + sizes[0] = max(sizes[0], len(pkg)) + sizes[1] = max(sizes[1], len(version)) + sizes[2] = max(sizes[2], len(suite)) + + fmt = "%%%is | %%%is | %%%is | " % tuple(sizes) + for pkg in packages: versions = d[pkg].keys() versions.sort(apt_pkg.version_compare) @@ -184,7 +198,7 @@ SELECT s.source, s.version, 'source', su.suite_name, c.name, m.name arches = d[pkg][version][suite] arches.sort(utils.arch_compare_sw) if Options["Format"] == "": #normal - sys.stdout.write("%10s | %10s | %13s | " % (pkg, version, suite)) + sys.stdout.write(fmt % (pkg, version, suite)) sys.stdout.write(", ".join(arches)) sys.stdout.write('\n') elif Options["Format"] in [ "control-suite", "heidi" ]: -- 1.7.10.4
pgpwHAVBYVf8q.pgp
Description: PGP signature