mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-17 05:40:25 +00:00
Add flake8 linting
This commit is contained in:
parent
9d310ba57e
commit
aaa823afd6
15 changed files with 28 additions and 22 deletions
1
Makefile
1
Makefile
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# flake8: noqa
|
||||
|
||||
from . import conf
|
||||
from .specs import ImageSpec
|
||||
from .pkgmeta import *
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
# flake8: noqa
|
||||
|
||||
from .fields import ProcessedImageField
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -54,6 +54,5 @@ class StrategyWrapper(object):
|
|||
def __unicode__(self):
|
||||
return unicode(self._wrapped)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return str(self._wrapped)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
from optparse import make_option
|
||||
from django.core.management.base import BaseCommand
|
||||
import re
|
||||
from ...files import ImageSpecCacheFile
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
# flake8: noqa
|
||||
|
||||
from .. import conf
|
||||
from .fields import ImageSpecField, ProcessedImageField
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# flake8: noqa
|
||||
|
||||
"""
|
||||
Imagekit image processors.
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue