diff options
author | Dan McGee <dan@archlinux.org> | 2011-12-12 02:52:27 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-12-12 02:52:27 +0100 |
commit | a60801bb7dbc18080e7f6106bcf9c707d2801c9d (patch) | |
tree | 12ba0f77316bbb87c1d15dc7d7d91a08fd85ed87 | |
parent | e65d2bc6db279240a03fece91e5332f8602859dc (diff) | |
download | archweb-a60801bb7dbc18080e7f6106bcf9c707d2801c9d.tar.gz archweb-a60801bb7dbc18080e7f6106bcf9c707d2801c9d.tar.xz |
PyLint suggested cleanups
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | devel/management/commands/reporead.py | 2 | ||||
-rw-r--r-- | devel/tests.py | 2 | ||||
-rw-r--r-- | devel/views.py | 18 | ||||
-rw-r--r-- | main/models.py | 6 | ||||
-rw-r--r-- | mirrors/templatetags/mirror_status.py | 4 | ||||
-rw-r--r-- | packages/management/commands/populate_signoffs.py | 1 | ||||
-rw-r--r-- | packages/models.py | 5 | ||||
-rw-r--r-- | packages/templatetags/package_extras.py | 5 | ||||
-rw-r--r-- | packages/utils.py | 2 | ||||
-rw-r--r-- | public/views.py | 2 |
10 files changed, 24 insertions, 23 deletions
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py index cc536b1..7e058af 100644 --- a/devel/management/commands/reporead.py +++ b/devel/management/commands/reporead.py @@ -24,7 +24,6 @@ from datetime import datetime from optparse import make_option from django.core.management.base import BaseCommand, CommandError -from django.contrib.auth.models import User from django.db import connections, router, transaction from django.db.utils import IntegrityError @@ -91,6 +90,7 @@ class Pkg(object): setattr(self, k, None) for k in self.collections: setattr(self, k, ()) + self.builddate = None self.files = None self.has_files = False diff --git a/devel/tests.py b/devel/tests.py index 3669117..01eed0f 100644 --- a/devel/tests.py +++ b/devel/tests.py @@ -99,7 +99,7 @@ class FindUserTest(TestCase): def test_cache(self): # simply look two of them up, but then do it repeatedly - for i in range(50): + for _ in range(5): self.assertEqual(self.user1, self.finder.find("XXX YYY <user1@example.com>")) self.assertEqual(self.user3, diff --git a/devel/views.py b/devel/views.py index 79272c9..2e62200 100644 --- a/devel/views.py +++ b/devel/views.py @@ -145,7 +145,7 @@ def change_profile(request): {'form': form, 'profile_form': profile_form}) @login_required -def report(request, report, username=None): +def report(request, report_name, username=None): title = 'Developer Report' packages = Package.objects.normal() names = attrs = user = None @@ -159,17 +159,17 @@ def report(request, report, username=None): maints = User.objects.filter(id__in=PackageRelation.objects.filter( type=PackageRelation.MAINTAINER).values('user')) - if report == 'old': + if report_name == 'old': title = 'Packages last built more than two years ago' cutoff = datetime.utcnow() - timedelta(days=365 * 2) packages = packages.filter( build_date__lt=cutoff).order_by('build_date') - elif report == 'long-out-of-date': + elif report_name == 'long-out-of-date': title = 'Packages marked out-of-date more than 90 days ago' cutoff = datetime.utcnow() - timedelta(days=90) packages = packages.filter( flag_date__lt=cutoff).order_by('flag_date') - elif report == 'big': + elif report_name == 'big': title = 'Packages with compressed size > 50 MiB' cutoff = 50 * 1024 * 1024 packages = packages.filter( @@ -182,7 +182,7 @@ def report(request, report, username=None): package.compressed_size) package.installed_size_pretty = filesizeformat( package.installed_size) - elif report == 'badcompression': + elif report_name == 'badcompression': title = 'Packages that have little need for compression' cutoff = 0.90 * F('installed_size') packages = packages.filter(compressed_size__gt=0, installed_size__gt=0, @@ -199,7 +199,7 @@ def report(request, report, username=None): ratio = package.compressed_size / float(package.installed_size) package.ratio = '%.2f' % ratio package.compress_type = package.filename.split('.')[-1] - elif report == 'uncompressed-man': + elif report_name == 'uncompressed-man': title = 'Packages with uncompressed manpages' # checking for all '.0'...'.9' + '.n' extensions bad_files = PackageFile.objects.filter(directory__contains='/man/', @@ -209,7 +209,7 @@ def report(request, report, username=None): bad_files = bad_files.filter(pkg__in=pkg_ids) bad_files = bad_files.values_list('pkg_id', flat=True).distinct() packages = packages.filter(id__in=set(bad_files)) - elif report == 'uncompressed-info': + elif report_name == 'uncompressed-info': title = 'Packages with uncompressed infopages' # we don't worry about looking for '*.info-1', etc., given that an # uncompressed root page probably exists in the package anyway @@ -220,7 +220,7 @@ def report(request, report, username=None): bad_files = bad_files.filter(pkg__in=pkg_ids) bad_files = bad_files.values_list('pkg_id', flat=True).distinct() packages = packages.filter(id__in=set(bad_files)) - elif report == 'unneeded-orphans': + elif report_name == 'unneeded-orphans': title = 'Orphan packages required by no other packages' owned = PackageRelation.objects.all().values('pkgbase') required = PackageDepend.objects.all().values('depname') @@ -273,7 +273,7 @@ class NewUserForm(forms.ModelForm): def save(self, commit=True): profile = super(NewUserForm, self).save(False) pwletters = ascii_letters + digits - password = ''.join([random.choice(pwletters) for i in xrange(8)]) + password = ''.join([random.choice(pwletters) for _ in xrange(8)]) user = User.objects.create_user(username=self.cleaned_data['username'], email=self.cleaned_data['private_email'], password=password) user.first_name = self.cleaned_data['first_name'] diff --git a/main/models.py b/main/models.py index cefebf7..c54e297 100644 --- a/main/models.py +++ b/main/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.db.models.signals import pre_save from django.contrib.auth.models import User from django.contrib.sites.models import Site -from django.forms import ValidationError from .fields import PositiveBigIntegerField, PGPKeyField from .utils import cache_function, make_choice, set_created_field @@ -229,7 +227,7 @@ class Package(models.Model): pkg__arch__in=self.applicable_arches()) # sort out duplicate packages; this happens if something has a double # versioned dep such as a kernel module - requiredby = [list(vals)[0] for k, vals in + requiredby = [list(vals)[0] for _, vals in groupby(requiredby, lambda x: x.pkg.id)] # find another package by this name in the opposite testing setup @@ -244,7 +242,7 @@ class Package(models.Model): # for each unique package name, try to screen our package list down to # those packages in the same testing category (yes or no) iff there is # a package in the same testing category. - for name, dep_pkgs in groupby(requiredby, lambda x: x.pkg.pkgname): + for _, dep_pkgs in groupby(requiredby, lambda x: x.pkg.pkgname): dep_pkgs = list(dep_pkgs) dep = dep_pkgs[0] if len(dep_pkgs) > 1: diff --git a/mirrors/templatetags/mirror_status.py b/mirrors/templatetags/mirror_status.py index 0031d83..9a363fb 100644 --- a/mirrors/templatetags/mirror_status.py +++ b/mirrors/templatetags/mirror_status.py @@ -10,7 +10,7 @@ def duration(value): return u'' # does not take microseconds into account total_secs = value.seconds + value.days * 24 * 3600 - mins, secs = divmod(total_secs, 60) + mins = total_secs // 60 hrs, mins = divmod(mins, 60) return '%d:%02d' % (hrs, mins) @@ -20,7 +20,7 @@ def hours(value): return u'' # does not take microseconds into account total_secs = value.seconds + value.days * 24 * 3600 - mins, secs = divmod(total_secs, 60) + mins = total_secs // 60 hrs, mins = divmod(mins, 60) if hrs == 1: return '%d hour' % hrs diff --git a/packages/management/commands/populate_signoffs.py b/packages/management/commands/populate_signoffs.py index 42496e9..97ba414 100644 --- a/packages/management/commands/populate_signoffs.py +++ b/packages/management/commands/populate_signoffs.py @@ -15,7 +15,6 @@ import sys from xml.etree.ElementTree import XML from django.conf import settings -from django.contrib.auth.models import User from django.core.management.base import NoArgsCommand from ...models import SignoffSpecification diff --git a/packages/models.py b/packages/models.py index 77cade6..1784389 100644 --- a/packages/models.py +++ b/packages/models.py @@ -1,7 +1,7 @@ from collections import namedtuple from django.db import models -from django.db.models.signals import pre_save, post_save +from django.db.models.signals import pre_save from django.contrib.auth.models import User from main.models import Arch, Repo @@ -167,6 +167,9 @@ class Signoff(models.Model): class FlagRequest(models.Model): + ''' + A notification the package is out-of-date submitted through the web site. + ''' user = models.ForeignKey(User, blank=True, null=True) user_email = models.EmailField('email address') created = models.DateTimeField(editable=False) diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py index 3eb7578..47b2fec 100644 --- a/packages/templatetags/package_extras.py +++ b/packages/templatetags/package_extras.py @@ -27,6 +27,7 @@ def url_unquote(original_url): class BuildQueryStringNode(template.Node): def __init__(self, sortfield): self.sortfield = sortfield + super(BuildQueryStringNode, self).__init__() def render(self, context): qs = parse_qs(context['current_query']) @@ -53,8 +54,8 @@ def do_buildsortqs(parser, token): @register.simple_tag def pkg_details_link(pkg): - template = '<a href="%s" title="View package details for %s">%s</a>' - return template % (pkg.get_absolute_url(), pkg.pkgname, pkg.pkgname) + link = '<a href="%s" title="View package details for %s">%s</a>' + return link % (pkg.get_absolute_url(), pkg.pkgname, pkg.pkgname) @register.simple_tag def multi_pkg_details(pkgs): diff --git a/packages/utils.py b/packages/utils.py index 5703db3..d4a9d8f 100644 --- a/packages/utils.py +++ b/packages/utils.py @@ -377,7 +377,7 @@ SELECT DISTINCT p1.pkgbase, r.name AND r.testing = %s AND p2.repo_id IN ( """ - sql += ','.join(['%s' for r in repos]) + sql += ','.join(['%s' for _ in repos]) sql += ")" params = [False, False] diff --git a/public/views.py b/public/views.py index 8fb60c7..bcae4bd 100644 --- a/public/views.py +++ b/public/views.py @@ -8,7 +8,7 @@ from devel.models import MasterKey from main.models import Arch, Repo, Donor from mirrors.models import MirrorUrl from news.models import News -from utils import get_recent_updates +from .utils import get_recent_updates def index(request): pkgs = get_recent_updates() |