[Yum-devel] [PATCH 2/2] Clean up some unnecessary/redundant code.

Ville Skyttä ville.skytta at iki.fi
Sat Apr 10 11:00:45 UTC 2010


---
 rpmUtils/updates.py |   13 +++++--------
 yum/__init__.py     |   11 +----------
 2 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/rpmUtils/updates.py b/rpmUtils/updates.py
index 68dee45..935a4ac 100644
--- a/rpmUtils/updates.py
+++ b/rpmUtils/updates.py
@@ -75,14 +75,11 @@ class Updates:
 
     def _delFromNADict(self, dict_, pkgtup):
         (n, a, e, v, r) = pkgtup
-        if dict_.has_key((n, a)):
-            dict_[(n, a)] = filter((e,v,r).__ne__, dict_[(n, a)])
-            if not dict_[(n, a)]:
-                del dict_[(n, a)]
-        if dict_.has_key((n, None)):
-            dict_[(n, None)] = filter((e,v,r).__ne__, dict_[(n, None)])
-            if not dict_[(n, None)]:
-                del dict_[(n, None)]
+        for aa in (a, None):
+            if (n, aa) in dict_:
+                dict_[(n, aa)] = filter((e,v,r).__ne__, dict_[(n, aa)])
+                if not dict_[(n, aa)]:
+                    del dict_[(n, aa)]
 
     def delPackage(self, pkgtup):
         """remove available pkgtup that is no longer available"""
diff --git a/yum/__init__.py b/yum/__init__.py
index ed64441..e45d70a 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2022,7 +2022,6 @@ class YumBase(depsolve.Depsolve):
         elif pkgnarrow == 'recent':
             now = time.time()
             recentlimit = now-(self.conf.recent*86400)
-            ftimehash = {}
             if showdups:
                 avail = self.pkgSack.returnPackages(patterns=patterns,
                                                     ignore_case=ic)
@@ -2034,15 +2033,7 @@ class YumBase(depsolve.Depsolve):
                     avail = []
             
             for po in avail:
-                ftime = int(po.filetime)
-                if ftime > recentlimit:
-                    if not ftimehash.has_key(ftime):
-                        ftimehash[ftime] = [po]
-                    else:
-                        ftimehash[ftime].append(po)
-
-            for sometime in ftimehash:
-                for po in ftimehash[sometime]:
+                if int(po.filetime) > recentlimit:
                     recent.append(po)
         
         
-- 
1.7.0.1



More information about the Yum-devel mailing list