[yum-git] Branch 'yum-3_2_X' - 3 commits - output.py yum/packageSack.py

James Antill james at linux.duke.edu
Wed Jun 11 17:40:09 UTC 2008


 output.py          |   74 +++++++++++++++++++++++++++++++++++++----------------
 yum/packageSack.py |    4 +-
 2 files changed, 54 insertions(+), 24 deletions(-)

New commits:
commit ea02674600a2281ba4cde55fc4f210312366bb6a
Author: James Antill <james at and.org>
Date:   Wed Jun 11 13:31:12 2008 -0400

    Fix seth's fix, of my fix, ... :)

diff --git a/yum/packageSack.py b/yum/packageSack.py
index a2b32f5..53cfced 100644
--- a/yum/packageSack.py
+++ b/yum/packageSack.py
@@ -370,7 +370,7 @@ class MetaSack(PackageSackBase):
         pkgs = calr("returnNewestByNameArch", naTup, patterns)
         pkgs = packagesNewestByNameArch(pkgs)
         if not pkgs:
-            raise Errors.PackageSackError, 'No Package Matching %s' % name          
+            raise PackageSackError, 'No Package Matching %s' % ", ".join(patterns or [])
         return pkgs
                 
     def returnNewestByName(self, name=None):
@@ -380,7 +380,7 @@ class MetaSack(PackageSackBase):
         pkgs = self._computeAggregateListResult("returnNewestByName", name)
         pkgs = packagesNewestByName(pkgs)
         if not pkgs:
-            raise Errors.PackageSackError, 'No Package Matching %s' % name        
+            raise PackageSackError, 'No Package Matching %s' % name        
         return pkgs
         
     def simplePkgList(self, patterns=None):
commit 99adc06c5df56022812ba7537ba476067c8f7a7c
Author: James Antill <james at and.org>
Date:   Wed Jun 11 13:28:13 2008 -0400

     More merges from the logging branch.
    
      Fix the "yum list php-pear-Str*" problem.
      Do the specspo. lookup/encoding for verbose matchcallback.
      Minor UI tweak for verbose matchcallback.

diff --git a/output.py b/output.py
index 6587da8..00b9020 100644
--- a/output.py
+++ b/output.py
@@ -29,6 +29,7 @@ import re # For YumTerm
 from urlgrabber.progress import TextMeter
 from urlgrabber.grabber import URLGrabError
 from yum.misc import sortPkgObj, prco_tuple_to_string, to_str, to_unicode, get_my_lang_code
+import yum.misc
 from rpmUtils.miscutils import checkSignals
 from yum.constants import *
 
@@ -243,13 +244,14 @@ class YumOutput:
     def simpleProgressBar(self, current, total, name=None):
         progressbar(current, total, name)
     
-    def simpleList(self, pkg):
+    def simpleList(self, pkg, ui_overflow=False):
         ver = pkg.printVer()
         na = '%s.%s' % (pkg.name, pkg.arch)
-        
+        if ui_overflow and len(na) > 40:
+            print "%s %s" % (na, "...")
+            na = ""
         print "%-40.40s %-22.22s %-16.16s" % (na, ver, pkg.repoid)
 
-
     def fmtKeyValFill(self, key, val):
         """ Return a key value pair in the common two column output format. """
         val = to_str(val)
@@ -276,20 +278,20 @@ class YumOutput:
 
         return "%s %s %s" % (beg, name, end)
 
+    def _enc(self, s):
+        """Get the translated version from specspo and ensure that
+        it's actually encoded in UTF-8."""
+        if type(s) == unicode:
+            s = s.encode("UTF-8")
+        if len(s) > 0:
+            for d in self.i18ndomains:
+                t = gettext.dgettext(d, s)
+                if t != s:
+                    s = t
+                    break
+        return to_unicode(s)
+
     def infoOutput(self, pkg):
-        def enc(s):
-            """Get the translated version from specspo and ensure that
-            it's actually encoded in UTF-8."""
-            if type(s) == unicode:
-                s = s.encode("UTF-8")
-            if len(s) > 0:
-                for d in self.i18ndomains:
-                    t = gettext.dgettext(d, s)
-                    if t != s:
-                        s = t
-                        break
-            s = unicode(s, "UTF-8")
-            return s
         print _("Name       : %s") % pkg.name
         print _("Arch       : %s") % pkg.arch
         if pkg.epoch != "0":
@@ -304,11 +306,11 @@ class YumOutput:
             print _("Buildtime  : %s") % time.ctime(pkg.buildtime)
             if hasattr(pkg, 'installtime'):
                 print _("Installtime: %s") % time.ctime(pkg.installtime)
-        print self.fmtKeyValFill(_("Summary    : "), enc(pkg.summary))
+        print self.fmtKeyValFill(_("Summary    : "), self._enc(pkg.summary))
         if pkg.url:
             print _("URL        : %s") % pkg.url
         print _("License    : %s") % pkg.license
-        print self.fmtKeyValFill(_("Description: "), enc(pkg.description))
+        print self.fmtKeyValFill(_("Description: "), self._enc(pkg.description))
         print ""
     
     def updatesObsoletesList(self, uotup, changetype):
@@ -335,7 +337,7 @@ class YumOutput:
                 lst.sort(sortPkgObj)
                 for pkg in lst:
                     if outputType == 'list':
-                        self.simpleList(pkg)
+                        self.simpleList(pkg, ui_overflow=True)
                     elif outputType == 'info':
                         self.infoOutput(pkg)
                     else:
@@ -477,7 +479,7 @@ class YumOutput:
             msg = '%s : ' % po
         else:
             msg = '%s.%s : ' % (po.name, po.arch)
-        msg = self.fmtKeyValFill(msg, po.summary)
+        msg = self.fmtKeyValFill(msg, self._enc(po.summary))
         if matchfor:
             msg = self.term.sub_bold(msg, matchfor)
         
@@ -489,10 +491,34 @@ class YumOutput:
             return
 
         print _('Matched from:')
-        for item in values:
+        for item in yum.misc.unique(values):
+            if po.name == item or po.summary == item:
+                continue # Skip double name/summary printing
+
+            can_overflow = True
+            if False: pass
+            elif po.description == item:
+                key = _("Description : ")
+                item = self._enc(item)
+            elif po.url == item:
+                key = _("URL         :  %s")
+                can_overflow = False
+            elif po.license == item:
+                key = _("License     :  %s")
+                can_overflow = False
+            elif item.startswith("/"):
+                key = _("Filename    :  %s")
+                item = self._enc(item)
+                can_overflow = False
+            else:
+                key = _("Other       : ")
+
             if matchfor:
                 item = self.term.sub_bold(item, matchfor)
-            print item
+            if can_overflow:
+                print self.fmtKeyValFill(key, item)
+            else:
+                print key % item
         print '\n\n'
 
     def matchcallback_verbose(self, po, values, matchfor=None):
commit 9170769f020d9e01cb1547a589a3fa727cb9d05a
Author: James Antill <james at and.org>
Date:   Wed Jun 11 13:01:12 2008 -0400

    Add times to verbose info. -- hand merge from logging branch

diff --git a/output.py b/output.py
index 01887b3..6587da8 100644
--- a/output.py
+++ b/output.py
@@ -300,6 +300,10 @@ class YumOutput:
         print _("Repo       : %s") % pkg.repoid
         if self.verbose_logger.isEnabledFor(logginglevels.DEBUG_3):
             print _("Committer  : %s") % pkg.committer
+            print _("Committime : %s") % time.ctime(pkg.committime)
+            print _("Buildtime  : %s") % time.ctime(pkg.buildtime)
+            if hasattr(pkg, 'installtime'):
+                print _("Installtime: %s") % time.ctime(pkg.installtime)
         print self.fmtKeyValFill(_("Summary    : "), enc(pkg.summary))
         if pkg.url:
             print _("URL        : %s") % pkg.url



More information about the Yum-cvs-commits mailing list