diff options
author | Dan McGee <dan@archlinux.org> | 2011-10-12 02:29:15 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-10-12 02:29:15 +0200 |
commit | 71e57570c262fffb11ca6e0dc97342119198f740 (patch) | |
tree | 3736af12cda316baffbcc4e5ba2a43f41901b847 | |
parent | a01a11cfad84bd44c1f5aeffcc0665bd93889e1d (diff) | |
download | archweb-71e57570c262fffb11ca6e0dc97342119198f740.tar.gz archweb-71e57570c262fffb11ca6e0dc97342119198f740.tar.xz |
Pylint suggested and other cleanups
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | main/middleware.py | 2 | ||||
-rw-r--r-- | mirrors/admin.py | 5 | ||||
-rw-r--r-- | news/views.py | 2 | ||||
-rw-r--r-- | packages/models.py | 2 | ||||
-rw-r--r-- | packages/views.py | 4 | ||||
-rw-r--r-- | public/utils.py | 2 | ||||
-rw-r--r-- | public/views.py | 11 | ||||
-rw-r--r-- | urls.py | 15 | ||||
-rw-r--r-- | visualize/views.py | 14 |
9 files changed, 34 insertions, 23 deletions
diff --git a/main/middleware.py b/main/middleware.py index f893c79..f417b54 100644 --- a/main/middleware.py +++ b/main/middleware.py @@ -4,7 +4,7 @@ from django.conf import settings from django.core.cache import cache -from django.utils.cache import get_cache_key, learn_cache_key, patch_response_headers, get_max_age +from django.utils.cache import learn_cache_key, patch_response_headers, get_max_age class UpdateCacheMiddleware(object): """ diff --git a/mirrors/admin.py b/mirrors/admin.py index 0632872..3786d8d 100644 --- a/mirrors/admin.py +++ b/mirrors/admin.py @@ -33,14 +33,15 @@ class MirrorUrlInlineAdmin(admin.TabularInline): extra = 3 # ripped off from django.forms.fields, adding netmask ability -ipv4nm_re = re.compile(r'^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}(/(\d|[1-2]\d|3[0-2])){0,1}$') +IPV4NM_RE = re.compile(r'^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}(/(\d|[1-2]\d|3[0-2])){0,1}$') + class IPAddressNetmaskField(forms.fields.RegexField): default_error_messages = { 'invalid': u'Enter a valid IPv4 address, possibly including netmask.', } def __init__(self, *args, **kwargs): - super(IPAddressNetmaskField, self).__init__(ipv4nm_re, *args, **kwargs) + super(IPAddressNetmaskField, self).__init__(IPV4NM_RE, *args, **kwargs) class MirrorRsyncForm(forms.ModelForm): class Meta: diff --git a/news/views.py b/news/views.py index 990ee15..7ac009b 100644 --- a/news/views.py +++ b/news/views.py @@ -32,7 +32,7 @@ def news_list(request): class NewsForm(forms.ModelForm): class Meta: model = News - exclude=('id', 'slug', 'author', 'postdate') + exclude = ('id', 'slug', 'author', 'postdate') def find_unique_slug(newsitem): '''Attempt to find a unique slug for this news item.''' diff --git a/packages/models.py b/packages/models.py index d2fe187..4cd3b1b 100644 --- a/packages/models.py +++ b/packages/models.py @@ -62,7 +62,7 @@ class Signoff(models.Model): # TODO: delayed import to avoid circular reference from main.models import Package return Package.objects.normal().filter(pkgbase=self.pkgbase, - pkgver=self.pkgver, pkgrel=self.pkgrel, epoch=pkg.epoch, + pkgver=self.pkgver, pkgrel=self.pkgrel, epoch=self.epoch, arch=self.arch, repo=self.repo) @property diff --git a/packages/views.py b/packages/views.py index 61e4d29..a8216c7 100644 --- a/packages/views.py +++ b/packages/views.py @@ -19,7 +19,7 @@ from django.views.generic.simple import direct_to_template from datetime import datetime from operator import attrgetter -import string +from string import Template from urllib import urlencode from main.models import Package, PackageFile, Arch, Repo @@ -575,7 +575,7 @@ def download(request, name, repo, arch): 'repo': pkg.repo.name.lower(), 'file': pkg.filename, } - url = string.Template('${host}${repo}/os/${arch}/${file}').substitute(values) + url = Template('${host}${repo}/os/${arch}/${file}').substitute(values) return redirect(url) def arch_differences(request): diff --git a/public/utils.py b/public/utils.py index 5900c67..30c76ac 100644 --- a/public/utils.py +++ b/public/utils.py @@ -1,6 +1,6 @@ from operator import attrgetter -from main.models import Arch, Package, Repo +from main.models import Arch, Package from main.utils import cache_function, groupby_preserve_order, PackageStandin class RecentUpdate(object): diff --git a/public/views.py b/public/views.py index 821e4d5..14dd635 100644 --- a/public/views.py +++ b/public/views.py @@ -5,7 +5,6 @@ from . import utils from django.conf import settings from django.contrib.auth.models import User -from django.db.models import Q from django.http import Http404 from django.views.generic import list_detail from django.views.generic.simple import direct_to_template @@ -34,18 +33,18 @@ USER_LISTS = { }, } -def userlist(request, type='devs'): +def userlist(request, user_type='devs'): users = User.objects.order_by('username').select_related('userprofile') - if type == 'devs': + if user_type == 'devs': users = users.filter(is_active=True, groups__name="Developers") - elif type == 'tus': + elif user_type == 'tus': users = users.filter(is_active=True, groups__name="Trusted Users") - elif type == 'fellows': + elif user_type == 'fellows': users = users.filter(is_active=False, groups__name__in=["Developers", "Trusted Users"]) else: raise Http404 - context = USER_LISTS[type].copy() + context = USER_LISTS[user_type].copy() context['users'] = users return direct_to_template(request, 'public/userlist.html', context) @@ -1,6 +1,7 @@ import os.path -from django.conf.urls.defaults import * +# Stupid Django. Don't remove these "unused" handler imports +from django.conf.urls.defaults import handler500, handler404, include, patterns from django.conf import settings from django.contrib import admin @@ -11,7 +12,7 @@ from django.views.i18n import null_javascript_catalog from feeds import PackageFeed, NewsFeed import sitemaps -sitemaps = { +our_sitemaps = { 'base': sitemaps.BaseSitemap, 'news': sitemaps.NewsSitemap, 'packages': sitemaps.PackagesSitemap, @@ -36,9 +37,9 @@ feeds_patterns = patterns('', # Sitemaps urlpatterns += patterns('django.contrib.sitemaps.views', (r'^sitemap.xml$', 'index', - {'sitemaps': sitemaps}), + {'sitemaps': our_sitemaps}), (r'^sitemap-(?P<section>.+)\.xml$', 'sitemap', - {'sitemaps': sitemaps}), + {'sitemaps': our_sitemaps}), ) # Authentication / Admin @@ -58,9 +59,9 @@ urlpatterns += patterns('public.views', {}, 'page-art'), (r'^svn/$', TemplateView.as_view(template_name='public/svn.html'), {}, 'page-svn'), - (r'^developers/$', 'userlist', { 'type':'devs' }, 'page-devs'), - (r'^trustedusers/$', 'userlist', { 'type':'tus' }, 'page-tus'), - (r'^fellows/$', 'userlist', { 'type':'fellows' }, 'page-fellows'), + (r'^developers/$', 'userlist', { 'user_type':'devs' }, 'page-devs'), + (r'^trustedusers/$', 'userlist', { 'user_type':'tus' }, 'page-tus'), + (r'^fellows/$', 'userlist', { 'user_type':'fellows' }, 'page-fellows'), (r'^donate/$', 'donate', {}, 'page-donate'), (r'^download/$', 'download', {}, 'page-download'), ) diff --git a/visualize/views.py b/visualize/views.py index 68f5d4a..f2b1d63 100644 --- a/visualize/views.py +++ b/visualize/views.py @@ -18,10 +18,20 @@ def arch_repo_data(): arches = Arch.objects.values_list('name', flat=True) repos = Repo.objects.values_list('name', flat=True) + def build_map(name, arch, repo): + key = '%s:%s' % (repo or '', arch or '') + return { + 'key': key, + 'name': name, + 'arch': arch, + 'repo': repo, + 'data': [], + } + # now transform these results into two mappings: one ordered (repo, arch), # and one ordered (arch, repo). - arch_groups = dict((a, { 'name': a, 'key': ':%s' % a, 'arch': a, 'repo': None, 'data': [] }) for a in arches) - repo_groups = dict((r, { 'name': r, 'key': '%s:' % r, 'arch': None, 'repo': r, 'data': [] }) for r in repos) + arch_groups = dict((a, build_map(a, a, None)) for a in arches) + repo_groups = dict((r, build_map(r, None, r)) for r in repos) for row in qs: arch = row['arch__name'] repo = row['repo__name'] |