commit:     696b07f1a4411ebdd5b66381ddc986494012785a
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 17 11:43:19 2019 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Sep 17 11:43:19 2019 +0000
URL:        https://gitweb.gentoo.org/proj/qa-scripts.git/commit/?id=696b07f1

pkg-newest-commit: Adjust padding to actual package name lengths

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 pkg-newest-commit.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/pkg-newest-commit.py b/pkg-newest-commit.py
index ecd5699..ef0af89 100755
--- a/pkg-newest-commit.py
+++ b/pkg-newest-commit.py
@@ -26,6 +26,11 @@ def main(argv):
                 packages.update('/'.join(x.rsplit('/', 3)[-3:-1])
                                 for x in glob.glob(os.path.join(
                                     args.work_dir, cat.strip(), '*/')))
+    if not packages:
+        print('No packages specified or found', file=sys.stderr)
+        return 1
+    pkg_max_len = max(len(x) for x in packages)
+    pkg_format = '{{:.<{}}} {{}} {{}}'.format(pkg_max_len+1)
 
     excludes = frozenset([
         # specify EAPI=0 explicitly
@@ -52,7 +57,7 @@ def main(argv):
                 commit, date = commit_data.split('|')
                 if commit in excludes:
                     continue
-                print('{:.<65} {} {}'.format(pkg + ' ', date, commit))
+                print(pkg_format.format(pkg + ' ', date, commit))
                 packages.remove(pkg)
                 if not packages:
                     break

Reply via email to