Hi all: 'yum search' outputs the package name,version, etc line for each field that it matches with the search value. This always bugged me; you have to wade through duplicate data to find what you want.
The attached patch only outputs the package name etc line once per matched package. Before: $ PYTHONPATH=. sudo python yummain.py search zsh -d1 | wc -l 12 $ PYTHONPATH=. sudo python yummain.py search git -d1 | wc -l 130 After: $ PYTHONPATH=. sudo python yummain.py search zsh -d1 | wc -l 6 $ PYTHONPATH=. sudo python yummain.py search git -d1 | wc -l 88 Oddly enough, it seems like the search and related display code is almost designed with this in mind. Am I covering something that has already been discussed? -James
diff --git a/yum/__init__.py b/yum/__init__.py
index afbdc60..a7aa676 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1164,24 +1164,24 @@ class YumBase(depsolve.YumDepsolver):
narrowed_list.extend(sack.searchPrimaryFields(sql_fields, s))
for po in narrowed_list:
+ tmpvalues = []
for field in fields:
- tmpvalues = []
value = getattr(po, field)
if value and value.find(s) != -1:
tmpvalues.append(value)
- if len(tmpvalues) > 0:
- yield (po, tmpvalues)
+ if len(tmpvalues) > 0:
+ yield (po, tmpvalues)
for po in self.rpmdb:
+ tmpvalues = []
for field in fields:
- tmpvalues = []
value = getattr(po, field)
if value and value.find(s) != -1:
tmpvalues.append(value)
- if len(tmpvalues) > 0:
- yield (po, tmpvalues)
+ if len(tmpvalues) > 0:
+ yield (po, tmpvalues)
def searchPackages(self, fields, criteria, callback=None):
"""Search specified fields for matches to criteria
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Yum-devel mailing list [email protected] https://lists.dulug.duke.edu/mailman/listinfo/yum-devel
