Fix PEP8 errors reported by the new flake8 version (except E128, which we ignore for the time being)

This commit is contained in:
Mathieu Pillard
2012-07-17 15:24:39 +02:00
parent 3723a67bf4
commit 73f8127b0f
8 changed files with 25 additions and 33 deletions

View File

@@ -12,7 +12,7 @@ install:
- pip install -e .
- pip install -r requirements/tests.txt Django==$DJANGO
before_script:
- flake8 compressor --ignore=E501
- flake8 compressor --ignore=E501,E128
script:
- make test
env:

View File

@@ -113,7 +113,7 @@ class Compressor(object):
return fd.read()
except IOError, e:
raise UncompressableFileError("IOError while processing "
"'%s': %s" % (filename, e))
"'%s': %s" % (filename, e))
except UnicodeDecodeError, e:
raise UncompressableFileError("UnicodeDecodeError while "
"processing '%s' with "

View File

@@ -19,7 +19,7 @@ class CompressorExtension(CompressorMixin, Extension):
if args[0].value not in self.compressors:
raise TemplateSyntaxError('compress kind may be one of: %s' %
(', '.join(self.compressors.keys())),
lineno)
lineno)
if parser.stream.skip_if('comma'):
modearg = parser.parse_expression()
# Allow mode to be defined as jinja2 name node

View File

@@ -91,8 +91,7 @@ class CompressorMixin(object):
# Take a shortcut if we really don't have anything to do
if ((not settings.COMPRESS_ENABLED and
not settings.COMPRESS_PRECOMPILERS)
and not forced):
not settings.COMPRESS_PRECOMPILERS) and not forced):
return self.get_original_content(context)
context['compressed'] = {'name': getattr(self, 'name', None)}

View File

@@ -219,10 +219,9 @@ class PrecompilerTemplatetagTestCase(TestCase):
</script>
{% endcompress %}"""
out = '\n'.join([
script(src="/media/CACHE/js/one.95cfb869eead.js"),
script(scripttype="", src="/media/js/one.js"),
script(src="/media/CACHE/js/one.81a2cd965815.js")])
out = '\n'.join([script(src="/media/CACHE/js/one.95cfb869eead.js"),
script(scripttype="", src="/media/js/one.js"),
script(src="/media/CACHE/js/one.81a2cd965815.js")])
self.assertEqual(out, render(template, self.context))
finally:
@@ -239,9 +238,8 @@ class PrecompilerTemplatetagTestCase(TestCase):
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/two.css"></link>
{% endcompress %}"""
out = ''.join([
'<link rel="stylesheet" type="text/css" href="/media/css/one.css" />',
'<link rel="stylesheet" type="text/css" href="/media/css/two.css" />'])
out = ''.join(['<link rel="stylesheet" type="text/css" href="/media/css/one.css" />',
'<link rel="stylesheet" type="text/css" href="/media/css/two.css" />'])
self.assertEqual(out, render(template, self.context))
finally:
@@ -259,10 +257,9 @@ class PrecompilerTemplatetagTestCase(TestCase):
<link rel="stylesheet" type="text/less" href="{{ MEDIA_URL }}css/url/test.css"/>
{% endcompress %}"""
out = ''.join([
'<link rel="stylesheet" type="text/css" href="/media/css/one.css" />',
'<link rel="stylesheet" type="text/css" href="/media/css/two.css" />',
'<link rel="stylesheet" href="/media/CACHE/css/test.c4f8a285c249.css" type="text/css" />'])
out = ''.join(['<link rel="stylesheet" type="text/css" href="/media/css/one.css" />',
'<link rel="stylesheet" type="text/css" href="/media/css/two.css" />',
'<link rel="stylesheet" href="/media/CACHE/css/test.c4f8a285c249.css" type="text/css" />'])
self.assertEqual(out, render(template, self.context))
finally:
settings.COMPRESS_ENABLED = self.old_enabled

View File

@@ -61,8 +61,7 @@ def _strformat(value, format_spec=""):
# TODO: thousand separator
pass
try:
if ((is_numeric and conversion == 's') or
(not is_integer and conversion in set('cdoxX'))):
if ((is_numeric and conversion == 's') or (not is_integer and conversion in set('cdoxX'))):
raise ValueError
if conversion == 'c':
conversion = 's'

View File

@@ -11,7 +11,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
import sys
import os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -182,8 +183,8 @@ htmlhelp_basename = 'django-compressordoc'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'django-compressor.tex', u'Django Compressor Documentation',
u'Django Compressor authors', 'manual'),
('index', 'django-compressor.tex', u'Django Compressor Documentation',
u'Django Compressor authors', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of

View File

@@ -32,12 +32,11 @@ standard_exclude_directories = ('.*', 'CVS', '_darcs', './build',
# Note: you may want to copy this into your setup.py file verbatim, as
# you can't import this from another package, when you don't know if
# that package is installed yet.
def find_package_data(
where='.', package='',
exclude=standard_exclude,
exclude_directories=standard_exclude_directories,
only_in_packages=True,
show_ignored=False):
def find_package_data(where='.', package='',
exclude=standard_exclude,
exclude_directories=standard_exclude_directories,
only_in_packages=True,
show_ignored=False):
"""
Return a dictionary suitable for use in ``package_data``
in a distutils ``setup.py`` file.
@@ -74,8 +73,7 @@ def find_package_data(
if os.path.isdir(fn):
bad_name = False
for pattern in exclude_directories:
if (fnmatchcase(name, pattern)
or fn.lower() == pattern.lower()):
if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()):
bad_name = True
if show_ignored:
print >> sys.stderr, (
@@ -84,8 +82,7 @@ def find_package_data(
break
if bad_name:
continue
if (os.path.isfile(os.path.join(fn, '__init__.py'))
and not prefix):
if (os.path.isfile(os.path.join(fn, '__init__.py')) and not prefix):
if not package:
new_package = name
else:
@@ -97,8 +94,7 @@ def find_package_data(
# is a file
bad_name = False
for pattern in exclude:
if (fnmatchcase(name, pattern)
or fn.lower() == pattern.lower()):
if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()):
bad_name = True
if show_ignored:
print >> sys.stderr, (