cli: Pretty print pisi search output

Slightly modified version of patch provided by Anıl Özbek

BUG:FIXED:17719
This commit is contained in:
Ozan Çağlayan
2011-06-13 08:53:08 +00:00
parent e17b54cda6
commit 62081bff45
+9 -1
View File
@@ -91,13 +91,21 @@ database.
get_info = db.get_package
get_name_sum = lambda pkg:(pkg.name, pkg.summary)
if pkgs:
maxlen = max([len(_pkg) for _pkg in pkgs])
for pkg in pkgs:
pkg_info = get_info(pkg)
name, summary = get_name_sum(pkg_info)
lenp = len(name)
name = replace.sub(pisi.util.colorize(r"\1", "brightred"), name)
if lang and summary.has_key(lang):
summary = replace.sub(pisi.util.colorize(r"\1", "brightred"), str(summary[lang]))
else:
summary = replace.sub(pisi.util.colorize(r"\1", "brightred"), str(summary))
print "%s - %s" % (name, summary)
name += ' ' * max(0, maxlen - lenp)
ctx.ui.info('%s - %s' % (name, summary))