[yum-git] Branch 'yum-3_2_X' - cli.py output.py yum/__init__.py

James Antill james at linux.duke.edu
Fri Jun 6 15:49:59 UTC 2008


 cli.py          |   12 +++++++++++-
 output.py       |   23 +++++++++++++++++++----
 yum/__init__.py |   17 ++++++++++++-----
 3 files changed, 42 insertions(+), 10 deletions(-)

New commits:
commit b23f24ba5e64020d228f2fda7ac858f2ad7c5985
Author: James Antill <james at and.org>
Date:   Fri Jun 6 11:46:17 2008 -0400

     Fix provides output, to have highlights and make it always "verbose".
     Give warning about old behaviour when nothing matches.

diff --git a/cli.py b/cli.py
index 8ff9d80..ff24ac6 100644
--- a/cli.py
+++ b/cli.py
@@ -734,10 +734,20 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         old_sdup = self.conf.showdupesfromrepos
         # For output, as searchPackageProvides() is always in showdups mode
         self.conf.showdupesfromrepos = True
-        matching = self.searchPackageProvides(args, callback=self.matchcallback)
+        cb = self.matchcallback_verbose
+        matching = self.searchPackageProvides(args, callback=cb,
+                                              callback_has_matchfor=True)
         self.conf.showdupesfromrepos = old_sdup
         
         if len(matching) == 0:
+            for arg in args:
+                if len(arg) and arg[0] == '*':
+                    continue
+                self.logger.warning(_('Warning: 3.0.x versions of yum would erronously match against filenames.\n You can use "%s*/%s%s" and/or "%s*bin/%s%s" to get that behaviour'),
+                                    self.term.MODE['bold'], arg,
+                                    self.term.MODE['normal'],
+                                    self.term.MODE['bold'], arg,
+                                    self.term.MODE['normal'])
             return 0, ['No Matches found']
         
         return 0, []
diff --git a/output.py b/output.py
index f7fbfbb..01887b3 100644
--- a/output.py
+++ b/output.py
@@ -462,7 +462,13 @@ class YumOutput:
     
         return(format % (number, space, symbols[depth]))
 
-    def matchcallback(self, po, values, matchfor=None):
+    def matchcallback(self, po, values, matchfor=None, verbose=None):
+        """ Output search/provides type callback matches. po is the pkg object,
+            values are the things in the po that we've matched.
+            If matchfor is passed, all the strings in that list will be
+            highlighted within the output.
+            verbose overrides logginglevel, if passed. """
+
         if self.conf.showdupesfromrepos:
             msg = '%s : ' % po
         else:
@@ -472,12 +478,21 @@ class YumOutput:
             msg = self.term.sub_bold(msg, matchfor)
         
         print msg
-        self.verbose_logger.debug(_('Matched from:'))
+
+        if verbose is None:
+            verbose = self.verbose_logger.isEnabledFor(logginglevels.DEBUG_3)
+        if not verbose:
+            return
+
+        print _('Matched from:')
         for item in values:
             if matchfor:
                 item = self.term.sub_bold(item, matchfor)
-            self.verbose_logger.debug('%s', item)
-        self.verbose_logger.debug('\n\n')
+            print item
+        print '\n\n'
+
+    def matchcallback_verbose(self, po, values, matchfor=None):
+        return self.matchcallback(po, values, matchfor, verbose=True)
         
     def reportDownloadSize(self, packages):
         """Report the total download size for a set of packages"""
diff --git a/yum/__init__.py b/yum/__init__.py
index bc0e4e4..a85f746 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1595,7 +1595,8 @@ class YumBase(depsolve.Depsolve):
         
         return matches
     
-    def searchPackageProvides(self, args, callback=None):
+    def searchPackageProvides(self, args, callback=None,
+                              callback_has_matchfor=False):
         
         matches = {}
         for arg in args:
@@ -1647,8 +1648,11 @@ class YumBase(depsolve.Depsolve):
                             tmpvalues.append(prov)
 
                 if len(tmpvalues) > 0:
-                    if callback:
-                        callback(po, tmpvalues)
+                    if callback: # No matchfor, on globs
+                        if not isglob and callback_has_matchfor:
+                            callback(po, tmpvalues, args)
+                        else:
+                            callback(po, tmpvalues)
                     matches[po] = tmpvalues
         
         # installed rpms, too
@@ -1674,7 +1678,10 @@ class YumBase(depsolve.Depsolve):
 
                     if len(tmpvalues) > 0:
                         if callback:
-                            callback(po, tmpvalues)
+                            if callback_has_matchfor:
+                                callback(po, tmpvalues, args)
+                            else:
+                                callback(po, tmpvalues)
                         matches[po] = tmpvalues
 
             else:
@@ -1698,7 +1705,7 @@ class YumBase(depsolve.Depsolve):
                             tmpvalues.append(item)
                 
                     if len(tmpvalues) > 0:
-                        if callback:
+                        if callback: # No matchfor, on globs
                             callback(po, tmpvalues)
                         matches[po] = tmpvalues
             



More information about the Yum-cvs-commits mailing list