[Yum-devel] [PATCH] Clean up the 'Transaction summary' report.

Zdeněk Pavlas zpavlas at redhat.com
Tue Jun 21 13:44:39 UTC 2011


---
 output.py |   43 +++++++++++++------------------------------
 1 files changed, 13 insertions(+), 30 deletions(-)

diff --git a/output.py b/output.py
index 3840f82..c146abf 100755
--- a/output.py
+++ b/output.py
@@ -38,7 +38,7 @@ import yum.misc
 from rpmUtils.miscutils import checkSignals, formatRequire
 from yum.constants import *
 
-from yum import logginglevels, _
+from yum import logginglevels, _, P_
 from yum.rpmtrans import RPMBaseCallback
 from yum.packageSack import packagesNewestByNameArch
 import yum.packages
@@ -1098,37 +1098,20 @@ class YumOutput:
             if lines:
                 out.append(totalmsg)
 
-        summary = _("""
+        out.append(_("""
 Transaction Summary
 %s
-""") % ('=' * self.term.columns,)
-        out.append(summary)
-        num_in = len(self.tsInfo.installed + self.tsInfo.depinstalled)
-        num_up = len(self.tsInfo.updated + self.tsInfo.depupdated)
-        num_rm = len(self.tsInfo.removed + self.tsInfo.depremoved)
-        num_re = len(self.tsInfo.reinstalled)
-        num_dg = len(self.tsInfo.downgraded)
-        if num_in:
-            out.append(_("""\
-Install   %5.5s Package(s)
-""") % num_in)
-        if num_up:
-            out.append(_("""\
-Upgrade   %5.5s Package(s)
-""") % num_up)
-        if num_rm:
-            out.append(_("""\
-Remove    %5.5s Package(s)
-""") % num_rm)
-        if num_re:
-            out.append(_("""\
-Reinstall %5.5s Package(s)
-""") % num_re)
-        if num_dg:
-            out.append(_("""\
-Downgrade %5.5s Package(s)
-""") % num_dg)
-        
+""") % ('=' * self.term.columns))
+        for action, count in (
+            ('Install', len(self.tsInfo.installed) + len(self.tsInfo.depinstalled)),
+            ('Upgrade', len(self.tsInfo.updated) + len(self.tsInfo.depupdated)),
+            ('Remove', len(self.tsInfo.removed) + len(self.tsInfo.depremoved)),
+            ('Reinstall', len(self.tsInfo.reinstalled)),
+            ('Downgrade', len(self.tsInfo.downgraded)),
+        ):
+            if count: out.append('%-9s %5d %s\n' % (
+                _(action), count, P_('Package', 'Packages', count),
+            ))
         return ''.join(out)
         
     def postTransactionOutput(self):
-- 
1.7.4.4



More information about the Yum-devel mailing list