[yum-cvs] yum/yum __init__.py,1.252,1.253
Jeremy Katz
katzj at linux.duke.edu
Wed Sep 13 22:20:00 UTC 2006
Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv11646/yum
Modified Files:
__init__.py
Log Message:
clean up some duplicate code to take advantage of the fact that the
rpmdb is now a package sack
Index: __init__.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/__init__.py,v
retrieving revision 1.252
retrieving revision 1.253
diff -u -r1.252 -r1.253
--- __init__.py 11 Sep 2006 21:01:13 -0000 1.252
+++ __init__.py 13 Sep 2006 22:19:57 -0000 1.253
@@ -1094,7 +1094,7 @@
"""Generator method to lighten memory load for some searches.
This is the preferred search function to use."""
self.doRepoSetup()
-
+ self.doRpmDBSetup()
for string in criteria:
restring = misc.refineSearchPattern(string)
@@ -1102,39 +1102,18 @@
except sre_constants.error, e:
raise Errors.MiscError, \
'Search Expression: %s is an invalid Regular Expression.\n' % string
-
- for po in self.pkgSack:
- tmpvalues = []
- for field in fields:
- value = po.returnSimple(field)
- if value and crit_re.search(value):
- tmpvalues.append(value)
-
- if len(tmpvalues) > 0:
- yield (po, tmpvalues)
-
- # do the same for installed pkgs
-
- self.doRpmDBSetup()
- for po in self.rpmdb: # this is more expensive so this is the top op
- tmpvalues = []
- for string in criteria:
- restring = misc.refineSearchPattern(string)
-
- try: crit_re = re.compile(restring, flags=re.I)
- except sre_constants.error, e:
- raise Errors.MiscError, \
- 'Search Expression: %s is an invalid Regular Expression.\n' % string
-
- for field in fields:
- value = po.returnSimple(field)
- if type(value) is types.ListType: # this is annoying
- value = str(value)
- if value and crit_re.search(value):
- tmpvalues.append(value)
-
- if len(tmpvalues) > 0:
- yield (po, tmpvalues)
+
+ for sack in self.pkgSack, self.rpmdb:
+ for po in sack:
+ tmpvalues = []
+ for field in fields:
+ value = po.returnSimple(field)
+ if value and crit_re.search(value):
+ tmpvalues.append(value)
+
+ if len(tmpvalues) > 0:
+ yield (po, tmpvalues)
+
def searchPackages(self, fields, criteria, callback=None):
"""Search specified fields for matches to criteria
More information about the Yum-cvs-commits
mailing list