summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-08-28 11:37:39 -0500
committerDan McGee <dan@archlinux.org>2010-08-28 11:41:19 -0500
commitd57696c8013d78f017972ae72efeeb441c954cb2 (patch)
tree5e9d9a70cda9a40b56dec08a1caf5b1e3e36edee /public
parent7dcdb0a31519c038e25436b49a60b9e54a41372b (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')
-rw-r--r--public/utils.py14
-rw-r--r--public/views.py2
2 files changed, 10 insertions, 6 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)
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