cli/listavailable: Fix inconsistent coloring (pb#17716)
Simplify code to fix the wrong coloring behaviour of pisi list-available command. Reported by: Anıl Özbek BUG:COMMENT:17716
This commit is contained in:
+12
-12
@@ -77,6 +77,7 @@ all repositories.
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
l = pisi.api.list_available(repo)
|
l = pisi.api.list_available(repo)
|
||||||
|
|
||||||
installed_list = pisi.api.list_installed()
|
installed_list = pisi.api.list_installed()
|
||||||
|
|
||||||
# maxlen is defined dynamically from the longest package name (#9021)
|
# maxlen is defined dynamically from the longest package name (#9021)
|
||||||
@@ -85,19 +86,18 @@ all repositories.
|
|||||||
|
|
||||||
l.sort()
|
l.sort()
|
||||||
for p in l:
|
for p in l:
|
||||||
|
if ctx.config.get_option('uninstalled') and p in installed_list:
|
||||||
|
continue
|
||||||
|
|
||||||
package = self.packagedb.get_package(p, repo)
|
package = self.packagedb.get_package(p, repo)
|
||||||
|
|
||||||
|
if p in installed_list:
|
||||||
|
package.name = util.colorize(package.name, 'green')
|
||||||
|
else:
|
||||||
|
package.name = util.colorize(package.name, 'brightwhite')
|
||||||
|
|
||||||
if self.options.long:
|
if self.options.long:
|
||||||
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')
|
ctx.ui.info(unicode(package)+'\n')
|
||||||
else:
|
else:
|
||||||
lenp = len(p)
|
package.name += ' ' * max(0, maxlen - len(p))
|
||||||
if p in installed_list:
|
ctx.ui.info('%s - %s ' % (package.name, unicode(package.summary)))
|
||||||
if ctx.config.get_option('uninstalled'):
|
|
||||||
continue
|
|
||||||
p = util.colorize(p, 'green')
|
|
||||||
p = util.colorize(p, 'brightwhite')
|
|
||||||
p = p + ' ' * max(0, maxlen - lenp)
|
|
||||||
ctx.ui.info('%s - %s ' % (p, unicode(package.summary)))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user