Browse files

Parameter indentation PEP8 fixes

  • Loading branch information...
1 parent 223bd17 commit 71d6464c5a5300ada146f70fddd816087aa78657 @SmileyChris committed Feb 5, 2013
View
4 easy_thumbnails/conf.py
@@ -77,8 +77,8 @@ def __setattr__(self, attr, value):
# reverted.
if attr not in self._added:
try:
- self._changed.setdefault(attr,
- getattr(django_settings, attr))
+ self._changed.setdefault(
+ attr, getattr(django_settings, attr))
except AttributeError:
self._added.append(attr)
return setattr(django_settings, attr, value)
View
6 easy_thumbnails/engine.py
@@ -28,7 +28,8 @@ def process_image(source, processor_options, processors=None):
"""
processor_options = _use_default_options(processor_options)
if processors is None:
- processors = [utils.dynamic_import(name)
+ processors = [
+ utils.dynamic_import(name)
for name in settings.THUMBNAIL_PROCESSORS]
image = source
for processor in processors:
@@ -72,7 +73,8 @@ def generate_source_image(source_file, processor_options, generators=None):
processor_options = _use_default_options(processor_options)
was_closed = source_file.closed
if generators is None:
- generators = [utils.dynamic_import(name)
+ generators = [
+ utils.dynamic_import(name)
for name in settings.THUMBNAIL_SOURCE_GENERATORS]
try:
source = source_file
View
58 easy_thumbnails/files.py
@@ -57,17 +57,19 @@ def get_thumbnailer(obj, relative_name=None):
obj = None
if not relative_name:
- raise ValueError("If object is not a FieldFile or Thumbnailer "
- "instance, the relative name must be provided")
+ raise ValueError(
+ "If object is not a FieldFile or Thumbnailer instance, the "
+ "relative name must be provided")
if isinstance(obj, File):
obj = obj.file
if isinstance(obj, Storage) or obj == default_storage:
source_storage = obj
obj = None
- return Thumbnailer(file=obj, name=relative_name,
- source_storage=source_storage, remote_source=obj is not None)
+ return Thumbnailer(
+ file=obj, name=relative_name, source_storage=source_storage,
+ remote_source=obj is not None)
def save_thumbnail(thumbnail_file, storage):
@@ -122,10 +124,10 @@ class ThumbnailFile(ImageFieldFile):
field (i.e. an ``ImageFieldFile`` object).
"""
def __init__(self, name, file=None, storage=None, thumbnail_options=None,
- *args, **kwargs):
+ *args, **kwargs):
fake_field = FakeField(storage=storage)
- super(ThumbnailFile, self).__init__(FakeInstance(), fake_field, name,
- *args, **kwargs)
+ super(ThumbnailFile, self).__init__(
+ FakeInstance(), fake_field, name, *args, **kwargs)
del self.field
if file:
self.file = file
@@ -166,9 +168,9 @@ def tag(self, alt='', use_size=None, **attrs):
:param alt: The ``alt=""`` text for the tag. Defaults to ``''``.
- :param use_size: Whether to get the size of the thumbnail image for use in
- the tag attributes. If ``None`` (default), it will be ``True`` or
- ``False`` depending on whether the file storage is local or not.
+ :param use_size: Whether to get the size of the thumbnail image for use
+ in the tag attributes. If ``None`` (default), it will be ``True``
+ or ``False`` depending on whether the file storage is local or not.
All other keyword parameters are added as (properly escaped) extra
attributes to the `img` tag.
@@ -243,8 +245,8 @@ class Thumbnailer(File):
thumbnail_processors = None
def __init__(self, file=None, name=None, source_storage=None,
- thumbnail_storage=None, remote_source=False, generate=True, *args,
- **kwargs):
+ thumbnail_storage=None, remote_source=False, generate=True,
+ *args, **kwargs):
super(Thumbnailer, self).__init__(file, name, *args, **kwargs)
self.source_storage = source_storage or default_storage
if not thumbnail_storage:
@@ -258,7 +260,8 @@ def __init__(self, file=None, name=None, source_storage=None,
# Set default properties. For backwards compatibilty, check to see
# if the attribute exists already (it could be set as a class property
# on a subclass) before getting it from settings.
- for default in ('basedir', 'subdir', 'prefix', 'quality', 'extension',
+ for default in (
+ 'basedir', 'subdir', 'prefix', 'quality', 'extension',
'preserve_extensions', 'transparency_extension',
'check_cache_miss'):
attr_name = 'thumbnail_%s' % default
@@ -296,14 +299,16 @@ def generate_thumbnail(self, thumbnail_options):
self.thumbnail_processors)
quality = thumbnail_options.get('quality', self.thumbnail_quality)
- filename = self.get_thumbnail_name(thumbnail_options,
+ filename = self.get_thumbnail_name(
+ thumbnail_options,
transparent=utils.is_transparent(thumbnail_image))
- data = engine.save_image(thumbnail_image, filename=filename,
- quality=quality).read()
+ img = engine.save_image(
+ thumbnail_image, filename=filename, quality=quality)
+ data = img.read()
- thumbnail = ThumbnailFile(filename, file=ContentFile(data),
- storage=self.thumbnail_storage,
+ thumbnail = ThumbnailFile(
+ filename, file=ContentFile(data), storage=self.thumbnail_storage,
thumbnail_options=thumbnail_options)
thumbnail.image = thumbnail_image
thumbnail._committed = False
@@ -320,7 +325,8 @@ def get_thumbnail_name(self, thumbnail_options, transparent=False):
source_extension = os.path.splitext(source_filename)[1][1:]
filename = '%s%s' % (self.thumbnail_prefix, source_filename)
preserve_extensions = self.thumbnail_preserve_extensions
- if preserve_extensions and (preserve_extensions == True or
+ if preserve_extensions and (
+ preserve_extensions is True or
source_extension.lower() in preserve_extensions):
extension = source_extension
elif transparent:
@@ -347,7 +353,7 @@ def get_thumbnail_name(self, thumbnail_options, transparent=False):
filename_parts = [filename]
if ('%(opts)s' in self.thumbnail_basedir or
- '%(opts)s' in self.thumbnail_subdir):
+ '%(opts)s' in self.thumbnail_subdir):
if extension != source_extension:
filename_parts.append(extension)
else:
@@ -383,15 +389,15 @@ def get_thumbnail(self, thumbnail_options, save=True, generate=None):
names = (opaque_name, transparent_name)
for filename in names:
if self.thumbnail_exists(filename):
- return ThumbnailFile(name=filename,
- storage=self.thumbnail_storage,
+ return ThumbnailFile(
+ name=filename, storage=self.thumbnail_storage,
thumbnail_options=thumbnail_options)
if generate is None:
generate = self.generate
if not generate:
- signals.thumbnail_missed.send(sender=self,
- options=thumbnail_options)
+ signals.thumbnail_missed.send(
+ sender=self, options=thumbnail_options)
return
thumbnail = self.generate_thumbnail(thumbnail_options)
@@ -533,7 +539,7 @@ def delete_thumbnails(self, source_cache=None):
deleted = 0
if source_cache:
thumbnail_storage_hash = utils.get_storage_hash(
- self.thumbnail_storage)
+ self.thumbnail_storage)
for thumbnail_cache in source_cache.thumbnails.all():
# Only attempt to delete the file if it was stored using the
# same storage as is currently used.
@@ -554,7 +560,7 @@ def get_thumbnails(self, *args, **kwargs):
source_cache = self.get_source_cache()
if source_cache:
thumbnail_storage_hash = utils.get_storage_hash(
- self.thumbnail_storage)
+ self.thumbnail_storage)
for thumbnail_cache in source_cache.thumbnails.all():
# Only iterate files which are stored using the current
# thumbnail storage.
View
4 easy_thumbnails/management/__init__.py
@@ -43,8 +43,8 @@ def all_thumbnails(path, recursive=True, prefix=None, subdir=None):
source_path, source_filename = os.path.split(source_filename)
if not source_filename.startswith(prefix):
continue
- source_filename = os.path.join(source_path,
- source_filename[len(prefix):])
+ source_filename = os.path.join(
+ source_path, source_filename[len(prefix):])
d['options'] = d['options'] and d['options'].split('_') or []
if subdir and rel_dir.endswith(subdir):
rel_dir = rel_dir[:-len(subdir)]
View
9 easy_thumbnails/management/commands/thumbnail_cleanup.py
@@ -11,7 +11,8 @@
except NameError:
from sets import Set as set # For Python 2.3
-thumb_re = re.compile(r'^%s(.*)\.\d{1,}x\d{1,}_[-\w]*q([1-9]\d?|100)\.jpg' %
+thumb_re = re.compile(
+ r'^%s(.*)\.\d{1,}x\d{1,}_[-\w]*q([1-9]\d?|100)\.jpg' %
settings.THUMBNAIL_PREFIX)
@@ -51,12 +52,12 @@ def clean_up():
# org_fn_alt is the expected original filename with extension
org_fn = m.group(1)
org_fn_exists = os.path.isfile(
- os.path.join(settings.MEDIA_ROOT, path, org_fn))
+ os.path.join(settings.MEDIA_ROOT, path, org_fn))
usc_pos = org_fn.rfind("_")
if usc_pos != -1:
- org_fn_alt = "%s.%s" % (org_fn[0:usc_pos],
- org_fn[usc_pos + 1:])
+ org_fn_alt = "%s.%s" % (
+ org_fn[0:usc_pos], org_fn[usc_pos + 1:])
org_fn_alt_exists = os.path.isfile(
os.path.join(settings.MEDIA_ROOT, path, org_fn_alt))
else:
View
4 easy_thumbnails/storage.py
@@ -16,5 +16,5 @@ def __init__(self, location=None, base_url=None, *args, **kwargs):
location = settings.THUMBNAIL_MEDIA_ROOT or None
if base_url is None:
base_url = settings.THUMBNAIL_MEDIA_URL or None
- super(ThumbnailFileSystemStorage, self).__init__(location, base_url,
- *args, **kwargs)
+ super(ThumbnailFileSystemStorage, self).__init__(
+ location, base_url, *args, **kwargs)
View
21 easy_thumbnails/templatetags/thumbnail.py
@@ -50,14 +50,13 @@ def render(self, context):
source = self.source_var.resolve(context)
except VariableDoesNotExist:
if raise_errors:
- raise VariableDoesNotExist("Variable '%s' does not exist." %
- self.source_var)
+ raise VariableDoesNotExist(
+ "Variable '%s' does not exist." % self.source_var)
return self.bail_out(context)
if not source:
if raise_errors:
raise TemplateSyntaxError(
- "Variable '%s' is an invalid source." % self.source_var
- )
+ "Variable '%s' is an invalid source." % self.source_var)
return self.bail_out(context)
# Resolve the thumbnail option values.
try:
@@ -87,16 +86,16 @@ def render(self, context):
opts['quality'] = int(opts['quality'])
except (TypeError, ValueError):
if raise_errors:
- raise TemplateSyntaxError("%r is an invalid quality." %
- opts['quality'])
+ raise TemplateSyntaxError(
+ "%r is an invalid quality." % opts['quality'])
return self.bail_out(context)
try:
thumbnail = get_thumbnailer(source).get_thumbnail(opts)
except Exception, e:
if raise_errors:
- raise TemplateSyntaxError(u"Couldn't get the thumbnail %s: %s" %
- (source, e))
+ raise TemplateSyntaxError(
+ u"Couldn't get the thumbnail %s: %s" % (source, e))
return self.bail_out(context)
# Return the thumbnail file url, or put the file on the context.
if self.context_name is None:
@@ -168,7 +167,8 @@ def thumbnail(parser, token):
context_name = None
if len(args) < 3:
- raise TemplateSyntaxError("Invalid syntax. Expected "
+ raise TemplateSyntaxError(
+ "Invalid syntax. Expected "
"'{%% %s source size [option1 option2 ...] %%}' or "
"'{%% %s source size [option1 option2 ...] as variable %%}'" %
(tag, tag))
@@ -233,7 +233,8 @@ def thumbnailer_passive(obj):
{% if avatar_thumb %}
<img src="{{ avatar_thumb.url }}" alt="" />
{% else %}
- <img src="{% static 'img/default-avatar-small.png' %}" alt="" />
+ <img src="{% static 'img/default-avatar-small.png' %}"
+ alt="" />
{% endif %}
{% endwith %}
{% endwith %}
View
2 easy_thumbnails/test.py
@@ -108,7 +108,7 @@ def tearDown(self):
return super(BaseTest, self).tearDown()
def create_image(self, storage, filename, size=(800, 600),
- image_mode='RGB', image_format='JPEG'):
+ image_mode='RGB', image_format='JPEG'):
"""
Generate a test image, returning the filename that it was saved as.
View
19 easy_thumbnails/tests/aliases.py
@@ -76,7 +76,8 @@ def test_partial_target(self):
self.assertEqual(
aliases.get('banner', target='some_app.Profile.avatar'),
{'size': (600, 80), 'crop': True})
- self.assertEqual(aliases.get('banner', target='some_app.Profile'),
+ self.assertEqual(
+ aliases.get('banner', target='some_app.Profile'),
{'size': (600, 80), 'crop': True})
self.assertEqual(aliases.get('banner', target='some_app'), None)
@@ -95,29 +96,33 @@ def test_target_fallback(self):
None)
def test_all(self):
- self.assertEqual(aliases.all(),
+ self.assertEqual(
+ aliases.all(),
{
'large': {'size': (500, 500)},
'medium': {'size': (300, 300)},
'small': {'size': (100, 100)},
})
- self.assertEqual(aliases.all('unknown_app'),
+ self.assertEqual(
+ aliases.all('unknown_app'),
{
'large': {'size': (500, 500)},
'medium': {'size': (300, 300)},
'small': {'size': (100, 100)},
})
- self.assertEqual(aliases.all('some_app.Profile'),
+ self.assertEqual(
+ aliases.all('some_app.Profile'),
{
'banner': {'size': (600, 80), 'crop': True},
'large': {'size': (200, 200)},
'medium': {'size': (300, 300)},
'small': {'size': (100, 100)},
})
- self.assertEqual(aliases.all('some_app.Profile.avatar'),
+ self.assertEqual(
+ aliases.all('some_app.Profile.avatar'),
{
'avatar': {'size': (80, 80), 'crop': True},
'banner': {'size': (600, 80), 'crop': True},
@@ -174,8 +179,8 @@ def setUp(self):
settings.MEDIA_ROOT = self.storage.temporary_location
def tearDown(self):
- signals.saved_file.disconnect(self.get_signal_handler(),
- sender=Profile)
+ signals.saved_file.disconnect(
+ self.get_signal_handler(), sender=Profile)
super(GenerationBase, self).tearDown()
def fake_save(self, instance):
View
55 easy_thumbnails/tests/files.py
@@ -21,23 +21,25 @@ def setUp(self):
self.thumbnailer.thumbnail_storage = self.storage
filename = self.create_image(self.remote_storage, 'test.jpg')
- self.remote_thumbnailer = files.get_thumbnailer(self.remote_storage,
- filename)
+ self.remote_thumbnailer = files.get_thumbnailer(
+ self.remote_storage, filename)
self.remote_thumbnailer.thumbnail_storage = self.remote_storage
# Create another thumbnailer for extension test.
self.ext_thumbnailer = files.get_thumbnailer(self.storage, filename)
self.ext_thumbnailer.thumbnail_storage = self.storage
# Generate test transparent images.
- filename = self.create_image(self.storage, 'transparent.png',
- image_mode='RGBA', image_format='PNG')
- self.transparent_thumbnailer = files.get_thumbnailer(self.storage,
- filename)
+ filename = self.create_image(
+ self.storage, 'transparent.png', image_mode='RGBA',
+ image_format='PNG')
+ self.transparent_thumbnailer = files.get_thumbnailer(
+ self.storage, filename)
self.transparent_thumbnailer.thumbnail_storage = self.storage
- filename = self.create_image(self.storage, 'transparent-greyscale.png',
- image_mode='LA', image_format='PNG')
+ filename = self.create_image(
+ self.storage, 'transparent-greyscale.png', image_mode='LA',
+ image_format='PNG')
self.transparent_greyscale_thumbnailer = files.get_thumbnailer(
self.storage, filename)
self.transparent_greyscale_thumbnailer.thumbnail_storage = self.storage
@@ -51,24 +53,28 @@ def test_tag(self):
local = self.thumbnailer.get_thumbnail({'size': (100, 100)})
remote = self.remote_thumbnailer.get_thumbnail({'size': (100, 100)})
- self.assertEqual(local.tag(), '<img alt="" height="75" '
+ self.assertEqual(
+ local.tag(), '<img alt="" height="75" src="%s" width="100" '
+ '/>' % local.url)
+ self.assertEqual(
+ local.tag(alt='A & B'), '<img alt="A &amp; B" height="75" '
'src="%s" width="100" />' % local.url)
- self.assertEqual(local.tag(alt='A & B'), '<img alt="A &amp; B" '
- 'height="75" src="%s" width="100" />' % local.url)
# Can turn off dimensions.
- self.assertEqual(remote.tag(use_size=False), '<img alt="" '
- 'src="%s" />' % remote.url)
+ self.assertEqual(
+ remote.tag(use_size=False), '<img alt="" src="%s" />' % remote.url)
# Thumbnails on remote storage don't get dimensions...
- self.assertEqual(remote.tag(), '<img alt="" '
- 'src="%s" />' % remote.url)
+ self.assertEqual(
+ remote.tag(), '<img alt="" src="%s" />' % remote.url)
# ...unless explicitly requested.
- self.assertEqual(remote.tag(use_size=True), '<img alt="" height="75" '
- 'src="%s" width="100" />' % remote.url)
+ self.assertEqual(
+ remote.tag(use_size=True),
+ '<img alt="" height="75" src="%s" width="100" />' % remote.url)
# All other arguments are passed through as attributes.
- self.assertEqual(local.tag(**{'rel': 'A&B', 'class': 'fish'}),
+ self.assertEqual(
+ local.tag(**{'rel': 'A&B', 'class': 'fish'}),
'<img alt="" class="fish" height="75" rel="A&amp;B" '
'src="%s" width="100" />' % local.url)
@@ -77,21 +83,24 @@ def test_transparent_thumbnailing(self):
{'size': (100, 100)})
thumb_file.seek(0)
thumb = Image.open(thumb_file)
- self.assertFalse(utils.is_transparent(thumb),
+ self.assertFalse(
+ utils.is_transparent(thumb),
"%s shouldn't be transparent." % thumb_file.name)
thumb_file = self.transparent_thumbnailer.get_thumbnail(
{'size': (100, 100)})
thumb_file.seek(0)
thumb = Image.open(thumb_file)
- self.assertTrue(utils.is_transparent(thumb),
+ self.assertTrue(
+ utils.is_transparent(thumb),
"%s should be transparent." % thumb_file.name)
thumb_file = self.transparent_greyscale_thumbnailer.get_thumbnail(
{'size': (100, 100)})
thumb_file.seek(0)
thumb = Image.open(thumb_file)
- self.assertTrue(utils.is_transparent(thumb),
+ self.assertTrue(
+ utils.is_transparent(thumb),
"%s should be transparent." % thumb_file.name)
def test_extensions(self):
@@ -181,8 +190,8 @@ def signal_handler(sender, **kwargs):
self.thumbnailer.get_thumbnail({'size': (100, 100)})
self.assertFalse(hasattr(self.thumbnailer, 'missed_signal'))
# Retrieval doesn't trigger signal.
- self.thumbnailer.get_thumbnail({'size': (100, 100)},
- generate=False)
+ self.thumbnailer.get_thumbnail(
+ {'size': (100, 100)}, generate=False)
self.assertFalse(hasattr(self.thumbnailer, 'missed_signal'))
# A thumbnail miss does trigger it.
options = {'size': (10, 20)}
View
32 easy_thumbnails/tests/models.py
@@ -14,8 +14,8 @@ def setUp(self):
self.storage = test.TemporaryStorage()
self.storage_hash = utils.get_storage_hash(self.storage)
self.source = Source.objects.create(
- name='Test source',
- storage_hash=self.storage_hash)
+ name='Test source',
+ storage_hash=self.storage_hash)
# Generate a test image, save it.
self.filename = self.create_image(self.storage, 'test.jpg')
@@ -27,24 +27,24 @@ def tearDown(self):
def test_create_file(self):
"""Create a new Thumbnail in the database"""
img = Thumbnail.objects.get_file(
- self.storage,
- self.filename,
- create=True,
- source=self.source)
+ self.storage,
+ self.filename,
+ create=True,
+ source=self.source)
self.assertEquals(img.name, self.filename)
def test_get_file(self):
"""Fetch an existing thumb from database"""
created = Thumbnail.objects.create(
- storage_hash=self.storage_hash,
- name=self.filename,
- source=self.source)
+ storage_hash=self.storage_hash,
+ name=self.filename,
+ source=self.source)
fetched = Thumbnail.objects.get_file(
- self.storage,
- self.filename,
- create=False)
+ self.storage,
+ self.filename,
+ create=False)
self.assertTrue(fetched)
self.assertEquals(created, fetched)
@@ -60,10 +60,10 @@ def test_get_file_check_cache(self):
pass
Thumbnail.objects.get_file(
- self.storage,
- self.filename,
- source=self.source,
- check_cache_miss=True)
+ self.storage,
+ self.filename,
+ source=self.source,
+ check_cache_miss=True)
# Now it is
try:
View
4 easy_thumbnails/tests/processors.py
@@ -64,8 +64,8 @@ def test_crop_corner(self):
expected = image.crop([700, 0, 800, 600])
self.assertImagesEqual(br_crop, expected)
- x_offset_crop = processors.scale_and_crop(image, (150, 600),
- crop='10,-10')
+ x_offset_crop = processors.scale_and_crop(
+ image, (150, 600), crop='10,-10')
expected = image.crop([15, 0, 165, 600])
self.assertImagesEqual(x_offset_crop, expected)
View
18 easy_thumbnails/tests/source_generators.py
@@ -44,8 +44,8 @@ def test_not_image(self):
"""
Non-images are passed silently.
"""
- self.assertEqual(source_generators.pil_image(StringIO('not an image')),
- None)
+ self.assertEqual(
+ source_generators.pil_image(StringIO('not an image')), None)
def test_nearly_image(self):
"""
@@ -68,9 +68,10 @@ def test_exif_orientation(self):
self.assertFalse(near_identical(reference, im))
im = source_generators.pil_image(StringIO(data.decode('base64')))
- self.assertTrue(near_identical(reference, im),
- 'EXIF orientation %s did not match reference image' %
- exif_orientation)
+ self.assertTrue(
+ near_identical(reference, im),
+ 'EXIF orientation %s did not match reference image' %
+ exif_orientation)
def test_switch_off_exif_orientation(self):
"""
@@ -82,7 +83,8 @@ def test_switch_off_exif_orientation(self):
im = image_from_b64(data)
self.assertFalse(near_identical(reference, im))
- im = source_generators.pil_image(StringIO(data.decode('base64')),
- exif_orientation=False)
- self.assertFalse(near_identical(reference, im),
+ im = source_generators.pil_image(
+ StringIO(data.decode('base64')), exif_orientation=False)
+ self.assertFalse(
+ near_identical(reference, im),
'Image should not have been modified')
View
29 easy_thumbnails/tests/templatetags.py
@@ -148,37 +148,38 @@ def testTag(self):
settings.THUMBNAIL_DEBUG = True
# Basic
- output = self.render_template('src="'
- '{% thumbnail source 240x240 %}"')
+ output = self.render_template(
+ 'src="{% thumbnail source 240x240 %}"')
expected = self.verify_thumbnail((240, 180), {'size': (240, 240)})
expected_url = ''.join((settings.MEDIA_URL, expected))
self.assertEqual(output, 'src="%s"' % expected_url)
# Size from context variable
# as a tuple:
- output = self.render_template('src="'
- '{% thumbnail source size %}"')
+ output = self.render_template(
+ 'src="{% thumbnail source size %}"')
expected = self.verify_thumbnail((90, 68), {'size': (90, 100)})
expected_url = ''.join((settings.MEDIA_URL, expected))
self.assertEqual(output, 'src="%s"' % expected_url)
# as a string:
- output = self.render_template('src="'
- '{% thumbnail source strsize %}"')
+ output = self.render_template(
+ 'src="{% thumbnail source strsize %}"')
expected = self.verify_thumbnail((80, 60), {'size': (80, 90)})
expected_url = ''.join((settings.MEDIA_URL, expected))
self.assertEqual(output, 'src="%s"' % expected_url)
# On context
- output = self.render_template('height:'
- '{% thumbnail source 240x240 as thumb %}{{ thumb.height }}')
+ output = self.render_template(
+ 'height:{% thumbnail source 240x240 as thumb %}{{ thumb.height }}')
self.assertEqual(output, 'height:180')
# With options and quality
- output = self.render_template('src="'
- '{% thumbnail source 240x240 sharpen crop quality=95 %}"')
+ output = self.render_template(
+ 'src="{% thumbnail source 240x240 sharpen crop quality=95 %}"')
# Note that the opts are sorted to ensure a consistent filename.
- expected = self.verify_thumbnail((240, 240), {'size': (240, 240),
- 'crop': True, 'sharpen': True, 'quality': 95})
+ expected = self.verify_thumbnail(
+ (240, 240),
+ {'size': (240, 240), 'crop': True, 'sharpen': True, 'quality': 95})
expected_url = ''.join((settings.MEDIA_URL, expected))
self.assertEqual(output, 'src="%s"' % expected_url)
@@ -228,8 +229,8 @@ def test_get(self):
'{{ t.small.url }}{% endwith %}'
)
output = self.render_template(src)
- expected = self.verify_thumbnail((20, 20),
- settings.THUMBNAIL_ALIASES['']['small'])
+ expected = self.verify_thumbnail(
+ (20, 20), settings.THUMBNAIL_ALIASES['']['small'])
expected_url = ''.join((settings.MEDIA_URL, expected))
self.assertEqual(output, expected_url)
View
9 easy_thumbnails/tests/widgets.py
@@ -30,8 +30,8 @@ def test_options_custom(self):
# Changing the options won't change the thumbnail options in the widget
# now.
options['crop'] = False
- self.assertEqual(widget.thumbnail_options,
- {'size': (300, 100), 'crop': True})
+ self.assertEqual(
+ widget.thumbnail_options, {'size': (300, 100), 'crop': True})
def test_render(self):
"""
@@ -101,9 +101,10 @@ def test_render_uploaded(self):
widget = widgets.ImageClearableFileInput()
base_widget = ClearableFileInput()
file_name = 'test.jpg'
- image = self.create_image(None, file_name) # storage=None to get raw content
+ # storage=None to get raw content.
+ image = self.create_image(None, file_name)
upload_file = SimpleUploadedFile(file_name, image.getvalue())
html = widget.render('photo', upload_file)
base_html = base_widget.render('photo', upload_file)
self.assertEqual(base_html, html)
- self.assertNotIn(file_name, html) # Widget is empty
+ self.assertNotIn(file_name, html) # Widget is empty.
View
3 easy_thumbnails/utils.py
@@ -64,7 +64,8 @@ def valid_processor_options(processors=None):
(and/or source generators)
"""
if processors is None:
- processors = [dynamic_import(p) for p in
+ processors = [
+ dynamic_import(p) for p in
settings.THUMBNAIL_PROCESSORS +
settings.THUMBNAIL_SOURCE_GENERATORS]
valid_options = set(['size', 'quality'])
View
3 easy_thumbnails/widgets.py
@@ -32,7 +32,8 @@ def get_thumbnail(self, value):
return thumbnailer.get_thumbnail(self.thumbnail_options)
def render(self, name, value, attrs=None):
- output = super(ImageClearableFileInput, self).render(name, value, attrs)
+ output = super(ImageClearableFileInput, self).render(
+ name, value, attrs)
if not value or not hasattr(value, 'storage'):
return output
thumb = self.get_thumbnail(value)

0 comments on commit 71d6464

Please sign in to comment.