From d57696c8013d78f017972ae72efeeb441c954cb2 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 28 Aug 2010 11:37:39 -0500 Subject: 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 --- public/utils.py | 14 +++++++++----- public/views.py | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'public') 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) diff --git a/public/views.py b/public/views.py index f2c649f9..be0ff80d 100644 --- a/public/views.py +++ b/public/views.py @@ -1,5 +1,5 @@ from main.models import Arch, Donor, MirrorUrl, News -from main.models import Package, Repo +from main.models import Repo from . import utils from django.contrib.auth.models import User -- cgit v1.2.3-54-g00ecf