[yum-commits] Branch 'yum-3_2_X' - rpmUtils/transaction.py yum/rpmsack.py

skvidal at osuosl.org skvidal at osuosl.org
Fri Oct 2 12:02:08 UTC 2009


 rpmUtils/transaction.py |   11 ++++++++---
 yum/rpmsack.py          |    6 +++++-
 2 files changed, 13 insertions(+), 4 deletions(-)

New commits:
commit 8a278aecf276aeb4b92f0d581495f37e1dd799ae
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Thu Oct 1 18:18:44 2009 -0400

    add a returnLeafNodes() to rpmsack
    
    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()

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


More information about the Yum-commits mailing list