diff options
author | Dan McGee <dan@archlinux.org> | 2010-08-28 11:37:39 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-08-28 11:41:19 -0500 |
commit | d57696c8013d78f017972ae72efeeb441c954cb2 (patch) | |
tree | 5e9d9a70cda9a40b56dec08a1caf5b1e3e36edee /public/utils.py | |
parent | 7dcdb0a31519c038e25436b49a60b9e54a41372b (diff) |
PyLint suggested cleanups
We had a bunch of extra imports, non-conventional variable names, spacing
issues, etc. that were relatively low-hanging fruit to clean up. Fix them
and make the code a bit cleaner in the process.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'public/utils.py')
-rw-r--r-- | public/utils.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/public/utils.py b/public/utils.py index c92cb264..2801c939 100644 --- a/public/utils.py +++ b/public/utils.py @@ -1,4 +1,6 @@ -from main.models import Arch, Repo, Package +from operator import attrgetter + +from main.models import Arch, Package from main.utils import cache_function @cache_function(300) @@ -7,18 +9,20 @@ def get_recent_updates(): # want to try and eliminate cross-architecture wasted space. Pull enough # packages that we can later do some screening and trim out the fat. pkgs = [] - for a in Arch.objects.all(): + for arch in Arch.objects.all(): # grab a few extra so we can hopefully catch everything we need - pkgs += list(Package.objects.select_related('arch', 'repo').filter(arch=a).order_by('-last_update')[:50]) + pkgs += list(Package.objects.select_related( + 'arch', 'repo').filter(arch=arch).order_by('-last_update')[:50]) pkgs.sort(key=lambda q: q.last_update) updates = [] ctr = 0 while ctr < 15 and len(pkgs) > 0: # not particularly happy with this logic, but it works. p = pkgs.pop() - samepkgs = filter(lambda q: p.is_same_version(q) and p.repo == q.repo, pkgs) + is_same = lambda q: p.is_same_version(q) and p.repo == q.repo + samepkgs = filter(is_same, pkgs) samepkgs.append(p) - samepkgs.sort(key=lambda q: q.arch.name) + samepkgs.sort(key=attrgetter('arch.name')) updates.append(samepkgs) for q in samepkgs: if p != q: pkgs.remove(q) |