[Yum-devel] [PATCH 2/2] Clean up some unnecessary/redundant code.
James Antill
james at fedoraproject.org
Mon Apr 12 14:46:32 UTC 2010
On Sat, 2010-04-10 at 14:00 +0300, Ville Skyttä wrote:
> ---
> 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)]
meh. I'd prefer a function, or just to leave it alone :)
> 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)
My guess is that the hash was used for sorting/grouping. But there's no
sort in the second ftimehash, which is weird ... and we resort the
packages on output anyway, and I hope nobody would count this as an
API...
ACK.
More information about the Yum-devel
mailing list