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 -e .
- pip install -r requirements/tests.txt Django==$DJANGO - pip install -r requirements/tests.txt Django==$DJANGO
before_script: before_script:
- flake8 compressor --ignore=E501 - flake8 compressor --ignore=E501,E128
script: script:
- make test - make test
env: env:

View File

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

View File

@@ -19,7 +19,7 @@ class CompressorExtension(CompressorMixin, Extension):
if args[0].value not in self.compressors: if args[0].value not in self.compressors:
raise TemplateSyntaxError('compress kind may be one of: %s' % raise TemplateSyntaxError('compress kind may be one of: %s' %
(', '.join(self.compressors.keys())), (', '.join(self.compressors.keys())),
lineno) lineno)
if parser.stream.skip_if('comma'): if parser.stream.skip_if('comma'):
modearg = parser.parse_expression() modearg = parser.parse_expression()
# Allow mode to be defined as jinja2 name node # 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 # Take a shortcut if we really don't have anything to do
if ((not settings.COMPRESS_ENABLED and if ((not settings.COMPRESS_ENABLED and
not settings.COMPRESS_PRECOMPILERS) not settings.COMPRESS_PRECOMPILERS) and not forced):
and not forced):
return self.get_original_content(context) return self.get_original_content(context)
context['compressed'] = {'name': getattr(self, 'name', None)} context['compressed'] = {'name': getattr(self, 'name', None)}

View File

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

View File

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

View File

@@ -11,7 +11,8 @@
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
import sys, os import sys
import os
# If extensions (or modules to document with autodoc) are in another directory, # 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 # 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 # Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]). # (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [ latex_documents = [
('index', 'django-compressor.tex', u'Django Compressor Documentation', ('index', 'django-compressor.tex', u'Django Compressor Documentation',
u'Django Compressor authors', 'manual'), u'Django Compressor authors', 'manual'),
] ]
# The name of an image file (relative to this directory) to place at the top of # 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 # 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 # you can't import this from another package, when you don't know if
# that package is installed yet. # that package is installed yet.
def find_package_data( def find_package_data(where='.', package='',
where='.', package='', exclude=standard_exclude,
exclude=standard_exclude, exclude_directories=standard_exclude_directories,
exclude_directories=standard_exclude_directories, only_in_packages=True,
only_in_packages=True, show_ignored=False):
show_ignored=False):
""" """
Return a dictionary suitable for use in ``package_data`` Return a dictionary suitable for use in ``package_data``
in a distutils ``setup.py`` file. in a distutils ``setup.py`` file.
@@ -74,8 +73,7 @@ def find_package_data(
if os.path.isdir(fn): if os.path.isdir(fn):
bad_name = False bad_name = False
for pattern in exclude_directories: for pattern in exclude_directories:
if (fnmatchcase(name, pattern) if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()):
or fn.lower() == pattern.lower()):
bad_name = True bad_name = True
if show_ignored: if show_ignored:
print >> sys.stderr, ( print >> sys.stderr, (
@@ -84,8 +82,7 @@ def find_package_data(
break break
if bad_name: if bad_name:
continue continue
if (os.path.isfile(os.path.join(fn, '__init__.py')) if (os.path.isfile(os.path.join(fn, '__init__.py')) and not prefix):
and not prefix):
if not package: if not package:
new_package = name new_package = name
else: else:
@@ -97,8 +94,7 @@ def find_package_data(
# is a file # is a file
bad_name = False bad_name = False
for pattern in exclude: for pattern in exclude:
if (fnmatchcase(name, pattern) if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()):
or fn.lower() == pattern.lower()):
bad_name = True bad_name = True
if show_ignored: if show_ignored:
print >> sys.stderr, ( print >> sys.stderr, (