Permalink
Browse files

Consistently use brackets rather than slashes for long lines

  • Loading branch information...
SmileyChris committed Feb 5, 2013
1 parent 35522aa commit 223bd17fc86d78f0ad61296405a8a2849651101d
View
@@ -92,8 +92,8 @@ class Settings(AppSettings):
THUMBNAIL_DEBUG = False
- THUMBNAIL_DEFAULT_STORAGE = 'easy_thumbnails.storage.'\
- 'ThumbnailFileSystemStorage'
+ THUMBNAIL_DEFAULT_STORAGE = (
+ 'easy_thumbnails.storage.ThumbnailFileSystemStorage')
THUMBNAIL_MEDIA_ROOT = ''
THUMBNAIL_MEDIA_URL = ''
View
@@ -1,6 +1,6 @@
from django.core.files.base import File, ContentFile
-from django.core.files.storage import get_storage_class, default_storage, \
- Storage
+from django.core.files.storage import (
+ get_storage_class, default_storage, Storage)
from django.db.models.fields.files import ImageFieldFile, FieldFile
import os
@@ -319,10 +319,10 @@ def get_thumbnail_name(self, thumbnail_options, transparent=False):
path, source_filename = os.path.split(self.name)
source_extension = os.path.splitext(source_filename)[1][1:]
filename = '%s%s' % (self.thumbnail_prefix, source_filename)
- if self.thumbnail_preserve_extensions == True or \
- (self.thumbnail_preserve_extensions and \
- source_extension.lower() in self.thumbnail_preserve_extensions):
- extension = source_extension
+ preserve_extensions = self.thumbnail_preserve_extensions
+ if preserve_extensions and (preserve_extensions == True or
+ source_extension.lower() in preserve_extensions):
+ extension = source_extension
elif transparent:
extension = self.thumbnail_transparency_extension
else:
@@ -1,7 +1,7 @@
import re
-from django.template import Library, Node, VariableDoesNotExist, \
- TemplateSyntaxError
+from django.template import (
+ Library, Node, VariableDoesNotExist, TemplateSyntaxError)
from django.utils.html import escape
from easy_thumbnails import utils
@@ -19,10 +19,10 @@ def create_image(mode='RGB', size=(800, 600)):
class ScaleAndCropTest(TestCase):
def assertImagesEqual(self, im1, im2, msg=None):
- if im1.size != im2.size or \
- ImageChops.difference(im1, im2).getbbox() is not None:
- raise self.failureException, \
- (msg or 'The two images were not identical')
+ if im1.size != im2.size or (
+ ImageChops.difference(im1, im2).getbbox() is not None):
+ raise self.failureException(
+ msg or 'The two images were not identical')
def test_scale(self):
image = create_image()
@@ -47,8 +47,9 @@ def verify_thumbnail(self, expected_size, options, source_filename=None,
source_filename = self.filename
self.assert_(isinstance(options, dict))
# Verify that the thumbnail file exists
- expected_filename = get_thumbnailer(self.storage, source_filename)\
- .get_thumbnail_name(options, transparent=transparent)
+ thumbnailer = get_thumbnailer(self.storage, source_filename)
+ expected_filename = thumbnailer.get_thumbnail_name(
+ options, transparent=transparent)
self.assert_(self.storage.exists(expected_filename),
'Thumbnail file %r not found' % expected_filename)
@@ -222,26 +223,32 @@ def tearDown(self):
class ThumbnailerFilterTest(ThumbnailerBase):
def test_get(self):
- src = '{% with t=filename|thumbnailer %}'\
+ src = (
+ '{% with t=filename|thumbnailer %}'
'{{ t.small.url }}{% endwith %}'
+ )
output = self.render_template(src)
expected = self.verify_thumbnail((20, 20),
settings.THUMBNAIL_ALIASES['']['small'])
expected_url = ''.join((settings.MEDIA_URL, expected))
self.assertEqual(output, expected_url)
def test_invalid(self):
- src = '{% with t=invalid_filename|thumbnailer %}'\
+ src = (
+ '{% with t=invalid_filename|thumbnailer %}'
'{{ t.small.url }}{% endwith %}'
+ )
output = self.render_template(src)
self.assertEqual(output, '')
class ThumbnailerPassiveFilterTest(ThumbnailerBase):
def test_check_generate(self):
- src = '{% with t=filename|thumbnailer_passive %}'\
+ src = (
+ '{% with t=filename|thumbnailer_passive %}'
'{{ t.generate }}{% endwith %}'
+ )
output = self.render_template(src)
self.assertEqual(output, 'False')
@@ -250,21 +257,27 @@ def test_get_existing(self):
# Pregenerate the thumbnail.
get_thumbnailer(self.storage, self.filename).get_thumbnail(options)
- src = '{% with t=filename|thumbnailer_passive %}'\
+ src = (
+ '{% with t=filename|thumbnailer_passive %}'
'{{ t.small.url }}{% endwith %}'
+ )
output = self.render_template(src)
expected = self.verify_thumbnail((20, 20), options)
expected_url = ''.join((settings.MEDIA_URL, expected))
self.assertEqual(output, expected_url)
def test_get_missing(self):
- src = '{% with t=filename|thumbnailer_passive %}'\
+ src = (
+ '{% with t=filename|thumbnailer_passive %}'
'{{ t.small.url }}{% endwith %}'
+ )
output = self.render_template(src)
self.assertEqual(output, '')
def test_invalid(self):
- src = '{% with t=invalid_filename|thumbnailer_passive %}'\
+ src = (
+ '{% with t=invalid_filename|thumbnailer_passive %}'
'{{ t.small.url }}{% endwith %}'
+ )
output = self.render_template(src)
self.assertEqual(output, '')
@@ -67,8 +67,10 @@ def test_custom_template(self):
"""
source_filename = self.create_image(self.storage, 'test.jpg')
widget = widgets.ImageClearableFileInput()
- widget.template_with_thumbnail = u'%(template)s<br />'\
+ widget.template_with_thumbnail = (
+ u'%(template)s<br />'
u'<a href="%(source_url)s">%(thumb)s</a> FOO'
+ )
source_file = self.storage.open(source_filename)
source_file.storage = self.storage
source_file.thumbnail_storage = self.storage
@@ -4,10 +4,14 @@
class ImageClearableFileInput(ClearableFileInput):
- template_with_initial = u'%(clear_template)s<br />'\
+ template_with_initial = (
+ u'%(clear_template)s<br />'
u'%(input_text)s: %(input)s'
- template_with_thumbnail = u'%(template)s<br />'\
+ )
+ template_with_thumbnail = (
+ u'%(template)s<br />'
u'<a href="%(source_url)s" target="_blank">%(thumb)s</a>'
+ )
def __init__(self, thumbnail_options=None, attrs=None):
thumbnail_options = thumbnail_options or {}

0 comments on commit 223bd17

Please sign in to comment.