commit 748b0d7283ad390ba1294cca81e6be580715a8f2
Author: James Antill <james@and.org>
Date:   Sat Apr 19 22:37:11 2008 -0400

    Add percentage used stats. to grouplist -v

diff --git a/cli.py b/cli.py
index cb16e76..e6ff93e 100644
--- a/cli.py
+++ b/cli.py
@@ -811,6 +811,15 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
 
     def returnGroupLists(self, userlist):
 
+        def _gpc(pkg_names):
+            if not pkg_names:
+                return ""
+            inst = 0
+            for pkg_name in pkg_names:
+                if self.rpmdb.contains(name=pkg_name):
+                    inst += 1
+            return "%3d%%" % ((inst * 100) / len(pkg_names))
+
         uservisible=1
             
         if len(userlist) > 0:
@@ -820,19 +829,56 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         installed, available = self.doGroupLists(uservisible=uservisible)
         mylang = yum.misc.get_my_lang_code()
         
+        maxlen = 0
+        if self.verbose_logger.isEnabledFor(yum.logginglevels.DEBUG_3):
+            for group in installed + available:
+                nlen = len(group.nameByLang(mylang))
+                if nlen > maxlen:
+                    maxlen = nlen
+
         if len(installed) > 0:
             self.verbose_logger.log(yum.logginglevels.INFO_2,
                 _('Installed Groups:'))
+            if maxlen:
+                self.verbose_logger.log(yum.logginglevels.INFO_2,
+                    _("   %-*s  %4s %4s %4s %4s"), maxlen, _('Group name'),
+                    _('Core'), _('Def'), _('Opt'), _('Cond'))
+
             for group in sorted(installed, key=lambda x: x.nameByLang(mylang)):
-                self.verbose_logger.log(yum.logginglevels.INFO_2, '   %s',
-                    group.nameByLang(mylang))
+                if not self.verbose_logger.isEnabledFor(yum.logginglevels.DEBUG_3):
+                    self.verbose_logger.log(yum.logginglevels.INFO_2, '   %s',
+                        group.nameByLang(mylang))
+                else:
+                    # In verbose mode output stats on installed PC
+                    self.verbose_logger.log(yum.logginglevels.INFO_2,
+                                            _('   %-*s: %4s %4s %4s %4s'),
+                                            maxlen, group.nameByLang(mylang),
+                                            _gpc(group.mandatory_packages),
+                                            _gpc(group.default_packages),
+                                            _gpc(group.optional_packages),
+                                            _gpc(group.conditional_packages))
         
         if len(available) > 0:
             self.verbose_logger.log(yum.logginglevels.INFO_2,
                 _('Available Groups:'))
+            if maxlen:
+                self.verbose_logger.log(yum.logginglevels.INFO_2,
+                    _("   %-*s  %4s %4s %4s %4s"), maxlen, _('Group name'),
+                    _('Core'), _('Def'), _('Opt'), _('Cond'))
+
             for group in sorted(available, key=lambda x: x.nameByLang(mylang)):
-                self.verbose_logger.log(yum.logginglevels.INFO_2, '   %s',
-                    group.nameByLang(mylang))
+                if not self.verbose_logger.isEnabledFor(yum.logginglevels.DEBUG_3):
+                    self.verbose_logger.log(yum.logginglevels.INFO_2, '   %s',
+                        group.nameByLang(mylang))
+                else:
+                    # In verbose mode output stats on installed PC
+                    self.verbose_logger.log(yum.logginglevels.INFO_2,
+                                            _('   %-*s: %4s %4s %4s %4s'),
+                                            maxlen, group.nameByLang(mylang),
+                                            _gpc(group.mandatory_packages),
+                                            _gpc(group.default_packages),
+                                            _gpc(group.optional_packages),
+                                            _gpc(group.conditional_packages))
 
             
         return 0, [_('Done')]
