[yum-commits] Branch 'yum-3_2_X' - 4 commits - rpmUtils/arch.py rpmUtils/miscutils.py yum/misc.py

James Antill james at osuosl.org
Fri Jan 23 05:43:31 UTC 2009


 rpmUtils/arch.py      |    5 +++--
 rpmUtils/miscutils.py |    7 +++++--
 yum/misc.py           |    8 +++-----
 3 files changed, 11 insertions(+), 9 deletions(-)

New commits:
commit 411f55e3d7179ce553242be8c0cff17ad80823bc
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Jan 21 23:38:17 2009 +0200

    Trivial cleanup to rangeCompare calling compareEVR.

diff --git a/rpmUtils/miscutils.py b/rpmUtils/miscutils.py
index d875f86..0b01f44 100644
--- a/rpmUtils/miscutils.py
+++ b/rpmUtils/miscutils.py
@@ -160,7 +160,7 @@ def rangeCompare(reqtuple, provtuple):
     if r is None:
         reqr = None
 
-    rc = rpmUtils.miscutils.compareEVR((e, v, r), (reqe, reqv, reqr))
+    rc = compareEVR((e, v, r), (reqe, reqv, reqr))
 
     # does not match unless
     if rc >= 1:
commit 9a43b63841794555caf4d618e26ed12747b5f346
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Jan 21 23:32:27 2009 +0200

    Set arch to 'src' for source packages in pkgTupleFromHeader().

diff --git a/rpmUtils/miscutils.py b/rpmUtils/miscutils.py
index e9fb3e5..d875f86 100644
--- a/rpmUtils/miscutils.py
+++ b/rpmUtils/miscutils.py
@@ -111,7 +111,10 @@ def pkgTupleFromHeader(hdr):
        None epoch to 0, as well."""
    
     name = hdr['name']
-    arch = hdr['arch']
+    if hdr[rpm.RPMTAG_SOURCERPM]:
+        arch = hdr['arch']
+    else:
+        arch = 'src'
     ver = hdr['version']
     rel = hdr['release']
     epoch = hdr['epoch']
commit cc85bd765a79d22ba99a5dffcaec1eb3a30fddf2
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Jan 21 22:57:43 2009 +0200

    getBestArchFromList() micro-optimization.

diff --git a/rpmUtils/arch.py b/rpmUtils/arch.py
index 5402455..21d0ccb 100644
--- a/rpmUtils/arch.py
+++ b/rpmUtils/arch.py
@@ -125,13 +125,14 @@ def getBestArchFromList(archlist, myarch=None):
         then return the best arch from the list for the canonArch.
     """
     
+    if len(archlist) == 0:
+        return None
+
     if myarch is None:
         myarch = canonArch
     
     mybestarch = getBestArch(myarch)
     
-    if len(archlist) == 0:
-        return None
     bestarch = getBestArch(myarch)
     if bestarch != myarch:
         bestarchchoice = getBestArchFromList(archlist, bestarch)
commit 12d9d60702a41a55bce19e01bb3151cfff0c31f0
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Jan 21 22:48:41 2009 +0200

    Use set instead of dict in misc.unique() for a small speedup.

diff --git a/yum/misc.py b/yum/misc.py
index 57373f6..c322c76 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -131,18 +131,16 @@ def unique(s):
     if n == 0:
         return []
 
-    # Try using a dict first, as that's the fastest and will usually
+    # Try using a set first, as that's the fastest and will usually
     # work.  If it doesn't work, it will usually fail quickly, so it
     # usually doesn't cost much to *try* it.  It requires that all the
     # sequence elements be hashable, and support equality comparison.
-    u = {}
     try:
-        for x in s:
-            u[x] = 1
+        u = set(s)
     except TypeError:
         del u  # move on to the next method
     else:
-        return u.keys()
+        return list(u)
 
     # We can't hash all the elements.  Second fastest is to sort,
     # which brings the equal elements together; then duplicates are


More information about the Yum-commits mailing list