Fixed flake8 E241

This commit is contained in:
Boryslav Larin 2013-11-02 21:37:48 +02:00
parent ee48f4af99
commit e737c009b8
25 changed files with 303 additions and 281 deletions

View File

@ -6,9 +6,11 @@ from django.utils.six.moves.urllib.request import urlopen
PING_URL = "http://www.google.com/webmasters/tools/ping" PING_URL = "http://www.google.com/webmasters/tools/ping"
class SitemapNotFound(Exception): class SitemapNotFound(Exception):
pass pass
def ping_google(sitemap_url=None, ping_url=PING_URL): def ping_google(sitemap_url=None, ping_url=PING_URL):
""" """
Alerts Google that the sitemap for the current site has been updated. Alerts Google that the sitemap for the current site has been updated.
@ -35,6 +37,7 @@ def ping_google(sitemap_url=None, ping_url=PING_URL):
params = urlencode({'sitemap': url}) params = urlencode({'sitemap': url})
urlopen("%s?%s" % (ping_url, params)) urlopen("%s?%s" % (ping_url, params))
class Sitemap(object): class Sitemap(object):
# This limit is defined by Google. See the index documentation at # This limit is defined by Google. See the index documentation at
# http://sitemaps.org/protocol.php#index. # http://sitemaps.org/protocol.php#index.
@ -105,11 +108,13 @@ class Sitemap(object):
self.latest_lastmod = latest_lastmod self.latest_lastmod = latest_lastmod
return urls return urls
class FlatPageSitemap(Sitemap): class FlatPageSitemap(Sitemap):
def items(self): def items(self):
current_site = Site.objects.get_current() current_site = Site.objects.get_current()
return current_site.flatpage_set.filter(registration_required=False) return current_site.flatpage_set.filter(registration_required=False)
class GenericSitemap(Sitemap): class GenericSitemap(Sitemap):
priority = None priority = None
changefreq = None changefreq = None

View File

@ -19,6 +19,7 @@ __all__ = ('SelectDateWidget',)
RE_DATE = re.compile(r'(\d{4})-(\d\d?)-(\d\d?)$') RE_DATE = re.compile(r'(\d{4})-(\d\d?)-(\d\d?)$')
def _parse_date_fmt(): def _parse_date_fmt():
fmt = get_format('DATE_FORMAT') fmt = get_format('DATE_FORMAT')
escaped = False escaped = False
@ -39,6 +40,7 @@ def _parse_date_fmt():
#if not self.first_select: self.first_select = 'day' #if not self.first_select: self.first_select = 'day'
return output return output
class SelectDateWidget(Widget): class SelectDateWidget(Widget):
""" """
A Widget that splits date input into three <select> boxes. A Widget that splits date input into three <select> boxes.

View File

@ -2,6 +2,7 @@
# Originally from https://bitbucket.org/ned/jslex # Originally from https://bitbucket.org/ned/jslex
import re import re
class Tok(object): class Tok(object):
""" """
A specification for a token class. A specification for a token class.
@ -15,6 +16,7 @@ class Tok(object):
self.regex = regex self.regex = regex
self.next = next self.next = next
def literals(choices, prefix="", suffix=""): def literals(choices, prefix="", suffix=""):
""" """
Create a regex from a space-separated list of literal `choices`. Create a regex from a space-separated list of literal `choices`.

View File

@ -11,6 +11,7 @@ background = dict((color_names[x], '4%s' % x) for x in range(8))
RESET = '0' RESET = '0'
opt_dict = {'bold': '1', 'underscore': '4', 'blink': '5', 'reverse': '7', 'conceal': '8'} opt_dict = {'bold': '1', 'underscore': '4', 'blink': '5', 'reverse': '7', 'conceal': '8'}
def colorize(text='', opts=(), **kwargs): def colorize(text='', opts=(), **kwargs):
""" """
Returns your text, enclosed in ANSI graphics codes. Returns your text, enclosed in ANSI graphics codes.
@ -55,6 +56,7 @@ def colorize(text='', opts=(), **kwargs):
text = '%s\x1b[%sm' % (text or '', RESET) text = '%s\x1b[%sm' % (text or '', RESET)
return '%s%s' % (('\x1b[%sm' % ';'.join(code_list)), text or '') return '%s%s' % (('\x1b[%sm' % ';'.join(code_list)), text or '')
def make_style(opts=(), **kwargs): def make_style(opts=(), **kwargs):
""" """
Returns a function with default parameters for colorize() Returns a function with default parameters for colorize()
@ -132,6 +134,7 @@ PALETTES = {
} }
DEFAULT_PALETTE = DARK_PALETTE DEFAULT_PALETTE = DARK_PALETTE
def parse_color_setting(config_string): def parse_color_setting(config_string):
"""Parse a DJANGO_COLORS environment variable to produce the system palette """Parse a DJANGO_COLORS environment variable to produce the system palette

View File

@ -19,6 +19,7 @@ from sphinx.util.nodes import set_source_info
simple_option_desc_re = re.compile( simple_option_desc_re = re.compile(
r'([-_a-zA-Z0-9]+)(\s*.*?)(?=,\s+(?:/|-|--)|$)') r'([-_a-zA-Z0-9]+)(\s*.*?)(?=,\s+(?:/|-|--)|$)')
def setup(app): def setup(app):
app.add_crossref_type( app.add_crossref_type(
directivename="setting", directivename="setting",

View File

@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh
[flake8] [flake8]
exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py,./django/utils/six.py,./django/conf/app_template/* exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py,./django/utils/six.py,./django/conf/app_template/*
ignore=E124,E125,E127,E128,E226,E241,E251,E302,E501,E261,W601 ignore=E124,E125,E127,E128,E226,E251,E302,E501,E261,W601
[metadata] [metadata]
license-file = LICENSE license-file = LICENSE

View File

@ -26,6 +26,7 @@ UNICODE_FILENAME = 'test-0123456789_中文_Orléans.jpg'
MEDIA_ROOT = sys_tempfile.mkdtemp() MEDIA_ROOT = sys_tempfile.mkdtemp()
UPLOAD_TO = os.path.join(MEDIA_ROOT, 'test_upload') UPLOAD_TO = os.path.join(MEDIA_ROOT, 'test_upload')
@override_settings(MEDIA_ROOT=MEDIA_ROOT) @override_settings(MEDIA_ROOT=MEDIA_ROOT)
class FileUploadTests(TestCase): class FileUploadTests(TestCase):
@classmethod @classmethod

View File

@ -8,11 +8,12 @@ from django.template import Template
from django.test import TestCase from django.test import TestCase
from django.test.utils import override_settings from django.test.utils import override_settings
class TestException(Exception): class TestException(Exception):
pass pass
# A middleware base class that tracks which methods have been called
# A middleware base class that tracks which methods have been called
class TestMiddleware(object): class TestMiddleware(object):
def __init__(self): def __init__(self):
self.process_request_called = False self.process_request_called = False
@ -38,28 +39,32 @@ class TestMiddleware(object):
def process_exception(self, request, exception): def process_exception(self, request, exception):
self.process_exception_called = True self.process_exception_called = True
# Middleware examples that do the right thing
# Middleware examples that do the right thing
class RequestMiddleware(TestMiddleware): class RequestMiddleware(TestMiddleware):
def process_request(self, request): def process_request(self, request):
super(RequestMiddleware, self).process_request(request) super(RequestMiddleware, self).process_request(request)
return HttpResponse('Request Middleware') return HttpResponse('Request Middleware')
class ViewMiddleware(TestMiddleware): class ViewMiddleware(TestMiddleware):
def process_view(self, request, view_func, view_args, view_kwargs): def process_view(self, request, view_func, view_args, view_kwargs):
super(ViewMiddleware, self).process_view(request, view_func, view_args, view_kwargs) super(ViewMiddleware, self).process_view(request, view_func, view_args, view_kwargs)
return HttpResponse('View Middleware') return HttpResponse('View Middleware')
class ResponseMiddleware(TestMiddleware): class ResponseMiddleware(TestMiddleware):
def process_response(self, request, response): def process_response(self, request, response):
super(ResponseMiddleware, self).process_response(request, response) super(ResponseMiddleware, self).process_response(request, response)
return HttpResponse('Response Middleware') return HttpResponse('Response Middleware')
class TemplateResponseMiddleware(TestMiddleware): class TemplateResponseMiddleware(TestMiddleware):
def process_template_response(self, request, response): def process_template_response(self, request, response):
super(TemplateResponseMiddleware, self).process_template_response(request, response) super(TemplateResponseMiddleware, self).process_template_response(request, response)
return TemplateResponse(request, Template('Template Response Middleware')) return TemplateResponse(request, Template('Template Response Middleware'))
class ExceptionMiddleware(TestMiddleware): class ExceptionMiddleware(TestMiddleware):
def process_exception(self, request, exception): def process_exception(self, request, exception):
super(ExceptionMiddleware, self).process_exception(request, exception) super(ExceptionMiddleware, self).process_exception(request, exception)
@ -67,27 +72,30 @@ class ExceptionMiddleware(TestMiddleware):
# Sample middlewares that raise exceptions # Sample middlewares that raise exceptions
class BadRequestMiddleware(TestMiddleware): class BadRequestMiddleware(TestMiddleware):
def process_request(self, request): def process_request(self, request):
super(BadRequestMiddleware, self).process_request(request) super(BadRequestMiddleware, self).process_request(request)
raise TestException('Test Request Exception') raise TestException('Test Request Exception')
class BadViewMiddleware(TestMiddleware): class BadViewMiddleware(TestMiddleware):
def process_view(self, request, view_func, view_args, view_kwargs): def process_view(self, request, view_func, view_args, view_kwargs):
super(BadViewMiddleware, self).process_view(request, view_func, view_args, view_kwargs) super(BadViewMiddleware, self).process_view(request, view_func, view_args, view_kwargs)
raise TestException('Test View Exception') raise TestException('Test View Exception')
class BadTemplateResponseMiddleware(TestMiddleware): class BadTemplateResponseMiddleware(TestMiddleware):
def process_template_response(self, request, response): def process_template_response(self, request, response):
super(BadTemplateResponseMiddleware, self).process_template_response(request, response) super(BadTemplateResponseMiddleware, self).process_template_response(request, response)
raise TestException('Test Template Response Exception') raise TestException('Test Template Response Exception')
class BadResponseMiddleware(TestMiddleware): class BadResponseMiddleware(TestMiddleware):
def process_response(self, request, response): def process_response(self, request, response):
super(BadResponseMiddleware, self).process_response(request, response) super(BadResponseMiddleware, self).process_response(request, response)
raise TestException('Test Response Exception') raise TestException('Test Response Exception')
class BadExceptionMiddleware(TestMiddleware): class BadExceptionMiddleware(TestMiddleware):
def process_exception(self, request, exception): def process_exception(self, request, exception):
super(BadExceptionMiddleware, self).process_exception(request, exception) super(BadExceptionMiddleware, self).process_exception(request, exception)