[yum-git] 2 commits - yum/sqlitesack.py
James Antill
james at linux.duke.edu
Sat Feb 9 04:58:50 UTC 2008
yum/sqlitesack.py | 59 +++++++++++++++++++-----------------------------------
1 file changed, 21 insertions(+), 38 deletions(-)
New commits:
commit 22ff45ac54467964aa20d0a30f2108e781b52d45
Author: James Antill <james at and.org>
Date: Fri Feb 8 23:50:41 2008 -0500
Remove more code, minor speed/clean up
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 1524c9d..1462009 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -809,12 +809,10 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
for (rep, db) in self.primarydb.items():
cur = db.cursor()
executeSQL(cur, query)
- for pkg in cur:
- if self._pkgKeyExcluded(rep, pkg['pkgKey']):
- continue
- if p in unmatched:
- unmatched.remove(p)
- matchres.append(self._packageByKey(rep, pkg['pkgKey']))
+ pmatches = self._sql_pkgKey2po(rep, cur)
+ if len(pmatches):
+ unmatched.remove(p)
+ matches.extend(pmatches)
exactmatch = misc.unique(exactmatch)
matched = misc.unique(matched)
commit f4e792469ea648e41e58eb34068be33588c721f7
Author: James Antill <james at and.org>
Date: Fri Feb 8 23:46:11 2008 -0500
Remove code duplication
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index dcca06e..1524c9d 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -363,6 +363,15 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
# this function is just silly and it reduces down to just this
return self.searchPrco(name, 'provides')
+ @staticmethod
+ def _sql_pkgKey2po(repo, cur, pkgs=None):
+ """ Takes a cursor and maps the pkgKey rows into a list of packages. """
+ if pkgs is None: pkgs = []
+ for ob in cur:
+ if self._pkgKeyExcluded(repo, ob['pkgKey']):
+ continue
+ pkgs.append(self._packageByKey(repo, ob['pkgKey']))
+ return pkgs
@catchSqliteException
def searchFiles(self, name, strict=False):
@@ -404,10 +413,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
%s length(filetypes) = 1 and \
dirname || ? || filenames \
%s ?" % (dirname_check, querytype), ('/', name))
- for ob in cur:
- if self._pkgKeyExcluded(rep, ob['pkgKey']):
- continue
- pkgs.append(self._packageByKey(rep, ob['pkgKey']))
+ self._sql_pkgKey2po(rep, cur, pkgs)
def filelist_globber(dirname, filenames):
files = filenames.split('/')
@@ -425,10 +431,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
%s length(filetypes) > 1 \
and filelist_globber(dirname,filenames)" % dirname_check)
- for ob in cur:
- if self._pkgKeyExcluded(rep, ob['pkgKey']):
- continue
- pkgs.append(self._packageByKey(rep, ob['pkgKey']))
+ self._sql_pkgKey2po(rep, cur, pkgs)
pkgs = misc.unique(pkgs)
return pkgs
@@ -448,10 +451,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
for (rep,cache) in self.primarydb.items():
cur = cache.cursor()
executeSQL(cur, basestring)
- for ob in cur:
- if self._pkgKeyExcluded(rep, ob['pkgKey']):
- continue
- result.append(self._packageByKey(rep, ob['pkgKey']))
+ self._sql_pkgKey2po(rep, cur, result)
return result
@catchSqliteException
@@ -635,10 +635,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
for (rep,cache) in self.primarydb.items():
cur = cache.cursor()
executeSQL(cur, "select DISTINCT pkgKey from %s where name %s ?" % (prcotype,querytype), (name,))
- for ob in cur:
- if self._pkgKeyExcluded(rep, ob['pkgKey']):
- continue
- results.append(self._packageByKey(rep, ob['pkgKey']))
+ self._sql_pkgKey2po(rep, cur, results)
# If it's not a provides or a filename, we are done
if prcotype != "provides" or name[0] != '/':
@@ -649,10 +646,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
for (rep,cache) in self.primarydb.items():
cur = cache.cursor()
executeSQL(cur, "select DISTINCT pkgKey from files where name %s ?" % querytype, (name,))
- for ob in cur:
- if self._pkgKeyExcluded(rep, ob['pkgKey']):
- continue
- results.append(self._packageByKey(rep, ob['pkgKey']))
+ self._sql_pkgKey2po(rep, cur, results)
matched = 0
globs = ['.*bin\/.*', '^\/etc\/.*', '^\/usr\/lib\/sendmail$']
@@ -771,10 +765,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
for (rep,cache) in self.primarydb.items():
cur = cache.cursor()
executeSQL(cur, "select pkgKey from packages where name=? and arch=?",naTup)
- for ob in cur:
- if self._pkgKeyExcluded(rep, ob['pkgKey']):
- continue
- allpkg.append(self._packageByKey(rep, ob['pkgKey']))
+ self._sql_pkgKey2po(rep, cur, allpkg)
# if we've got zilch then raise
if not allpkg:
@@ -793,10 +784,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
for (rep,cache) in self.primarydb.items():
cur = cache.cursor()
executeSQL(cur, "select pkgKey from packages where name=?", (name,))
- for ob in cur:
- if self._pkgKeyExcluded(rep, ob['pkgKey']):
- continue
- allpkg.append(self._packageByKey(rep, ob['pkgKey']))
+ self._sql_pkgKey2po(rep, cur, allpkg)
# if we've got zilch then raise
if not allpkg:
@@ -925,10 +913,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
for (rep,cache) in self.primarydb.items():
cur = cache.cursor()
executeSQL(cur, q)
- for ob in cur:
- if self._pkgKeyExcluded(rep, ob['pkgKey']):
- continue
- returnList.append(self._packageByKey(rep, ob['pkgKey']))
+ self._sql_pkgKey2po(rep, cur, returnList)
return returnList
@catchSqliteException
More information about the Yum-cvs-commits
mailing list