[yum-git] 4 commits - yum/__init__.py yum/packageSack.py
James Antill
james at linux.duke.edu
Mon Mar 17 21:25:14 UTC 2008
yum/__init__.py | 10 +++-------
yum/packageSack.py | 44 ++++++++++++++++++++++++++------------------
2 files changed, 29 insertions(+), 25 deletions(-)
New commits:
commit 1e54b09810720f132949e7910931cfe529ac4ac7
Author: James Antill <james at and.org>
Date: Mon Mar 17 17:24:36 2008 -0400
Merge MetaSack.returnObs and PackageSack.returnObs
diff --git a/yum/packageSack.py b/yum/packageSack.py
index 3424625..85fc25e 100644
--- a/yum/packageSack.py
+++ b/yum/packageSack.py
@@ -316,17 +316,13 @@ class MetaSack(PackageSackBase):
# FIXME - this is slooooooooooooooooooooooooooooooow
# get the dict back
obsdict = self._computeAggregateDictResult("returnObsoletes")
- # get a sack of the newest pkgs
- obstups = obsdict.keys()
- newest_tup_dict = {}
- for pkg in self.returnNewestByName():
- if not newest_tup_dict.has_key(pkg.pkgtup):
- newest_tup_dict[pkg.pkgtup] = 1
+
+ newest_tups = set((pkg.pkgtup for pkg in self.returnNewestByName()))
# go through each of the keys of the obs dict and see if it is in the
# sack of newest pkgs - if it is not - remove the entry
- for obstup in obstups:
- if not newest_tup_dict.has_key(obstup):
+ for obstup in obsdict.keys():
+ if obstup not in newest_tups:
del obsdict[obstup]
return obsdict
commit 8a1148bf7ce9393d1362982e9e9cca515c046534
Author: James Antill <james at and.org>
Date: Mon Mar 17 17:18:21 2008 -0400
export packagesNewestByName* and use in __init__
diff --git a/yum/__init__.py b/yum/__init__.py
index e736d58..c38afe9 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -49,7 +49,7 @@ from parser import ConfigPreProcessor
import transactioninfo
import urlgrabber
from urlgrabber.grabber import URLGrabError
-from packageSack import ListPackageSack
+from packageSack import packagesNewestByName, packagesNewestByNameArch
import depsolve
import plugins
import logginglevels
@@ -1981,9 +1981,7 @@ class YumBase(depsolve.Depsolve):
if len(pkglist) == 1:
return pkglist[0]
- mysack = ListPackageSack()
- mysack.addList(pkglist)
- bestlist = mysack.returnNewestByNameArch() # get rid of all lesser vers
+ bestlist = packagesNewestByNameArch(pkglist)
best = bestlist[0]
for pkg in bestlist[1:]:
@@ -2131,9 +2129,7 @@ class YumBase(depsolve.Depsolve):
pkgs = use
- pkgSack = ListPackageSack(pkgs)
- pkgs = pkgSack.returnNewestByName()
- del(pkgSack)
+ pkgs = packagesNewestByName(pkgs)
pkgbyname = {}
for pkg in pkgs:
diff --git a/yum/packageSack.py b/yum/packageSack.py
index 126bc0f..3424625 100644
--- a/yum/packageSack.py
+++ b/yum/packageSack.py
@@ -366,14 +366,14 @@ class MetaSack(PackageSackBase):
foo.i386 will be compared"""
calr = self._computeAggregateListResult
pkgs = calr("returnNewestByNameArch", naTup, patterns)
- return _list_pkg_sack_newest_namearch(pkgs)
+ return packagesNewestByNameArch(pkgs)
def returnNewestByName(self, name=None):
"""return list of newest packages based on name matching
this means(in name.arch form): foo.i386 and foo.noarch will
be compared to each other for highest version"""
pkgs = self._computeAggregateListResult("returnNewestByName", name)
- return _list_pkg_sack_newest_name(pkgs)
+ return packagesNewestByName(pkgs)
def simplePkgList(self, patterns=None):
"""returns a list of pkg tuples (n, a, e, v, r)"""
@@ -821,7 +821,7 @@ class PackageSack(PackageSackBase):
return matches
-def _list_pkg_sack_newest_name(pkgs):
+def packagesNewestByName(pkgs):
newest = {}
for pkg in pkgs:
key = pkg.name
@@ -829,7 +829,7 @@ def _list_pkg_sack_newest_name(pkgs):
continue
newest[key] = pkg
return newest.values()
-def _list_pkg_sack_newest_namearch(pkgs):
+def packagesNewestByNameArch(pkgs):
newest = {}
for pkg in pkgs:
key = (pkg.name, pkg.arch)
commit abd42e9f7756b71c314f791d7aeeadf511db9ea0
Author: James Antill <james at and.org>
Date: Mon Mar 17 17:09:58 2008 -0400
Don't create ListPackageSack() just to do a newest operation
diff --git a/yum/packageSack.py b/yum/packageSack.py
index b3c851a..126bc0f 100644
--- a/yum/packageSack.py
+++ b/yum/packageSack.py
@@ -364,21 +364,16 @@ class MetaSack(PackageSackBase):
this means(in name.arch form): foo.i386 and foo.noarch are not
compared to each other for highest version only foo.i386 and
foo.i386 will be compared"""
- bestofeach = ListPackageSack()
calr = self._computeAggregateListResult
- bestofeach.addList(calr("returnNewestByNameArch", naTup, patterns))
-
- return bestofeach.returnNewestByNameArch(naTup, patterns)
-
+ pkgs = calr("returnNewestByNameArch", naTup, patterns)
+ return _list_pkg_sack_newest_namearch(pkgs)
def returnNewestByName(self, name=None):
"""return list of newest packages based on name matching
this means(in name.arch form): foo.i386 and foo.noarch will
be compared to each other for highest version"""
-
- bestofeach = ListPackageSack()
- bestofeach.addList(self._computeAggregateListResult("returnNewestByName", name))
- return bestofeach.returnNewestByName(name)
+ pkgs = self._computeAggregateListResult("returnNewestByName", name)
+ return _list_pkg_sack_newest_name(pkgs)
def simplePkgList(self, patterns=None):
"""returns a list of pkg tuples (n, a, e, v, r)"""
@@ -826,6 +821,23 @@ class PackageSack(PackageSackBase):
return matches
+def _list_pkg_sack_newest_name(pkgs):
+ newest = {}
+ for pkg in pkgs:
+ key = pkg.name
+ if key in newest and pkg <= newest[key]:
+ continue
+ newest[key] = pkg
+ return newest.values()
+def _list_pkg_sack_newest_namearch(pkgs):
+ newest = {}
+ for pkg in pkgs:
+ key = (pkg.name, pkg.arch)
+ if key in newest and pkg <= newest[key]:
+ continue
+ newest[key] = pkg
+ return newest.values()
+
class ListPackageSack(PackageSack):
"""Derived class from PackageSack to build new Sack from list of
pkgObjects - like one returned from self.returnNewestByNameArch()
commit 7d8b2a5d711be87a560223c0787be810832e3b16
Author: James Antill <james at and.org>
Date: Mon Mar 17 15:08:51 2008 -0400
Fix packagesack.returnObs
diff --git a/yum/packageSack.py b/yum/packageSack.py
index 01c17c2..b3c851a 100644
--- a/yum/packageSack.py
+++ b/yum/packageSack.py
@@ -600,7 +600,7 @@ class PackageSack(PackageSackBase):
# go through each of the keys of the obs dict and see if it is in the
# sack of newest pkgs - if it is not - remove the entry
- for obstup in obs.iterkeys():
+ for obstup in obs.keys():
if obstup not in newest_tups:
del obs[obstup]
More information about the Yum-cvs-commits
mailing list