[Yum-devel] [PATCH] add a returnLeafNodes() to rpmsack
Seth Vidal
skvidal at fedoraproject.org
Thu Oct 1 22:20:21 UTC 2009
modifies transaction.returnLeafNodes() to take an optional argument
that returns headers and indexes so we can convert it quickly
to package objects. This makes self.rpmdb.returnLeafNodes() about 2x
faster than it was with the PackageSackBase.returnLeafNodes()
---
rpmUtils/transaction.py | 11 ++++++++---
yum/rpmsack.py | 6 +++++-
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/rpmUtils/transaction.py b/rpmUtils/transaction.py
index 664643e..e0c6152 100644
--- a/rpmUtils/transaction.py
+++ b/rpmUtils/transaction.py
@@ -107,9 +107,11 @@ class TransactionWrapper:
return reserrors
- def returnLeafNodes(self):
+ def returnLeafNodes(self, headers=False):
"""returns a list of package tuples (n,a,e,v,r) that are not required by
- any other package on the system"""
+ any other package on the system
+ If headers is True then it will return a list of (header, index) tuples
+ """
req = {}
orphan = []
@@ -143,7 +145,10 @@ class TransactionWrapper:
preq = preq + 1
if preq == 0:
- orphan.append(tup)
+ if headers:
+ orphan.append((h, mi.instance()))
+ else:
+ orphan.append(tup)
return orphan
diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index fd05f9b..93e14ec 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -434,7 +434,11 @@ class RPMDBPackageSack(PackageSackBase):
def excludeArchs(self, archlist):
pass
-
+
+ def returnLeafNodes(self, repoid=None):
+ ts = self.readOnlyTS()
+ return [ self._makePackageObject(h, mi) for (h, mi) in ts.returnLeafNodes(headers=True) ]
+
# Helper functions
def _all_packages(self):
'''Generator that yield (header, index) for all packages
--
1.6.2.5
More information about the Yum-devel
mailing list