Add flake8 linting

This commit is contained in:
Matthew Tretter 2012-11-05 23:34:32 -05:00
parent 9d310ba57e
commit aaa823afd6
15 changed files with 28 additions and 22 deletions

View file

@ -1,4 +1,5 @@
test:
flake8 --ignore=E501,E126,E127,E128 imagekit tests
export PYTHONPATH=$(PWD):$(PYTHONPATH); \
django-admin.py test --settings=tests.settings tests

View file

@ -1,3 +1,5 @@
# flake8: noqa
from . import conf
from .specs import ImageSpec
from .pkgmeta import *

View file

@ -27,7 +27,7 @@ class AdminThumbnail(object):
try:
thumbnail = getattr(obj, self.image_field)
except AttributeError:
raise Exception('The property %s is not defined on %s.' % \
raise Exception('The property %s is not defined on %s.' %
(self.image_field, obj.__class__.__name__))
original_image = getattr(thumbnail, 'source_file', None) or thumbnail

View file

@ -1 +1,3 @@
# flake8: noqa
from .fields import ProcessedImageField

View file

@ -12,7 +12,7 @@ else:
def deferred_validate(file):
try:
import celery
import celery # NOQA
except:
raise ImportError("Deferred validation requires the the 'celery' library")
validate_now_task.delay(file)

View file

@ -54,6 +54,5 @@ class StrategyWrapper(object):
def __unicode__(self):
return unicode(self._wrapped)
def __str__(self):
return str(self._wrapped)

View file

@ -1,3 +1,5 @@
# flake8: noqa
# Required PIL classes may or may not be available from the root namespace
# depending on the installation method used.
try:

View file

@ -1,4 +1,3 @@
from optparse import make_option
from django.core.management.base import BaseCommand
import re
from ...files import ImageSpecCacheFile

View file

@ -1,2 +1,4 @@
# flake8: noqa
from .. import conf
from .fields import ImageSpecField, ProcessedImageField

View file

@ -26,9 +26,9 @@ class ImageSpecField(SpecHostField):
"""
def __init__(self, processors=None, format=None, options=None,
image_field=None, storage=None, autoconvert=None,
image_cache_backend=None, image_cache_strategy=None, spec=None,
id=None):
image_field=None, storage=None, autoconvert=None,
image_cache_backend=None, image_cache_strategy=None, spec=None,
id=None):
SpecHost.__init__(self, processors=processors, format=format,
options=options, storage=storage, autoconvert=autoconvert,
@ -58,8 +58,8 @@ class ProcessedImageField(models.ImageField, SpecHostField):
attr_class = ProcessedImageFieldFile
def __init__(self, processors=None, format=None, options=None,
verbose_name=None, name=None, width_field=None, height_field=None,
autoconvert=True, spec=None, spec_id=None, **kwargs):
verbose_name=None, name=None, width_field=None, height_field=None,
autoconvert=True, spec=None, spec_id=None, **kwargs):
"""
The ProcessedImageField constructor accepts all of the arguments that
the :class:`django.db.models.ImageField` constructor accepts, as well

View file

@ -15,16 +15,16 @@ class ImageSpecFileDescriptor(object):
if field_name:
source_file = getattr(instance, field_name)
else:
image_fields = [getattr(instance, f.attname) for f in \
instance.__class__._meta.fields if \
image_fields = [getattr(instance, f.attname) for f in
instance.__class__._meta.fields if
isinstance(f, ImageField)]
if len(image_fields) == 0:
raise Exception('%s does not define any ImageFields, so your' \
' %s ImageSpecField has no image to act on.' % \
raise Exception('%s does not define any ImageFields, so your'
' %s ImageSpecField has no image to act on.' %
(instance.__class__.__name__, self.attname))
elif len(image_fields) > 1:
raise Exception('%s defines multiple ImageFields, but you' \
' have not specified an image_field for your %s' \
raise Exception('%s defines multiple ImageFields, but you'
' have not specified an image_field for your %s'
' ImageSpecField.' % (instance.__class__.__name__,
self.attname))
else:

View file

@ -1,3 +1,5 @@
# flake8: noqa
"""
Imagekit image processors.

View file

@ -1,4 +1,4 @@
from .base import Anchor
from .base import Anchor # noqa
from .utils import histogram_entropy
from ..lib import Image, ImageChops, ImageDraw, ImageStat

View file

@ -1,5 +1,4 @@
from imagekit.lib import Image
import warnings
from .base import Anchor
@ -211,10 +210,8 @@ class ResizeToFit(object):
ratio = float(self.width) / cur_width
new_dimensions = (int(round(cur_width * ratio)),
int(round(cur_height * ratio)))
if (cur_width > new_dimensions[0] or cur_height > new_dimensions[1]) or \
self.upscale:
img = Resize(new_dimensions[0],
new_dimensions[1]).process(img)
if (cur_width > new_dimensions[0] or cur_height > new_dimensions[1]) or self.upscale:
img = Resize(new_dimensions[0], new_dimensions[1]).process(img)
if self.mat_color is not None:
img = ResizeCanvas(self.width, self.height, self.mat_color, anchor=self.anchor).process(img)
return img

View file

@ -110,7 +110,7 @@ def spec(parser, token):
"""
bits = token.split_contents()
tag_name = bits.pop(0)
tag_name = bits.pop(0) # noqa
if len(bits) == 4 and bits[2] == 'as':
return SpecResultAssignmentNode(