From e7576a76decbcb3093c63c38bafd34f015b99e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Wed, 14 Jan 2009 13:23:42 +0000 Subject: [PATCH] * pisi/cli/listavailable.py (print_packages): Resize the first column dynamically according to the longest package name (#9021) and fix some other displaying issues concerning 'listavailable' command. * pisi/cli/listinstalled.py (run): Resize the first column dynamically according to the longest package name. BUG:FIXED:9021 --- ChangeLog | 7 +++++++ pisi/cli/listavailable.py | 14 ++++++++++++-- pisi/cli/listinstalled.py | 8 +++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 54d9c750..a1e8cb3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-01-14 Ozan Çağlayan + * pisi/cli/listavailable.py (print_packages): Resize the first column + dynamically according to the longest package name (#9021) and fix some + other displaying issues concerning 'listavailable' command. + * pisi/cli/listinstalled.py (run): Resize the first column + dynamically according to the longest package name. + 2009-01-09 Gökçen Eraslan * pisi/actionsapi/cmaketools.py: If both -v and -d parameters are given, pass VERBOSE=1 parameter to make command. This results printing diff --git a/pisi/cli/listavailable.py b/pisi/cli/listavailable.py index 3b7167fa..c2438c26 100644 --- a/pisi/cli/listavailable.py +++ b/pisi/cli/listavailable.py @@ -78,16 +78,26 @@ all repositories. else: l = pisi.api.list_available(repo) installed_list = pisi.api.list_installed() + + # maxlen is defined dynamically from the longest package name (#9021) + if l: + maxlen = max([len(_p) for _p in l]) + l.sort() for p in l: package = self.packagedb.get_package(p, repo) if self.options.long: - ctx.ui.info(unicode(package)) + if p in installed_list: + package.name = util.colorize(package.name, 'green') + else: + package.name = util.colorize(package.name, 'brightwhite') + ctx.ui.info(unicode(package)+'\n') else: lenp = len(p) if p in installed_list: if ctx.config.get_option('uninstalled'): continue p = util.colorize(p, 'green') - p = p + ' ' * max(0, 15 - lenp) + p = util.colorize(p, 'brightwhite') + p = p + ' ' * max(0, maxlen - lenp) ctx.ui.info('%s - %s ' % (p, unicode(package.summary))) diff --git a/pisi/cli/listinstalled.py b/pisi/cli/listinstalled.py index 3426185b..af0fee1c 100644 --- a/pisi/cli/listinstalled.py +++ b/pisi/cli/listinstalled.py @@ -67,6 +67,11 @@ Usage: list-installed installed = list(set(installed) & set(component_pkgs)) installed.sort() + + # Resize the first column according to the longest package name + if installed: + maxlen = max([len(_p) for _p in installed]) + if self.options.install_info: ctx.ui.info(_('Package Name |St| Version| Rel.| Build| Distro| Date')) print '========================================================================' @@ -79,4 +84,5 @@ Usage: list-installed elif self.options.install_info: ctx.ui.info('%-15s |%s' % (package.name, inst_info.one_liner())) else: - ctx.ui.info('%15s - %s' % (package.name, unicode(package.summary))) + package.name = package.name + ' ' * (maxlen - len(package.name)) + ctx.ui.info('%s - %s' % (package.name, unicode(package.summary)))