Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit 1cb6ff7

Browse files
committed
Fix flake8 complaints
1 parent 2e5437f commit 1cb6ff7

File tree

7 files changed

+20
-27
lines changed

7 files changed

+20
-27
lines changed

ckeditor_demo/demo_application/views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ class CkEditorFormView(generic.FormView):
1313
def get_success_url(self):
1414
return reverse('ckeditor-form')
1515

16+
1617
ckeditor_form_view = CkEditorFormView.as_view()

ckeditor_demo/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,6 @@
126126
CKEDITOR_IMAGE_BACKEND = "pillow"
127127
CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'
128128

129-
#New
129+
# New
130130
IMAGE_QUALITY = 40
131-
THUMBNAIL_SIZE=(300,300)
131+
THUMBNAIL_SIZE = (300, 300)

ckeditor_uploader/image/pillow_backend.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,16 @@
22

33
import os
44
from io import BytesIO
5+
from PIL import Image, ImageOps
56

7+
from django.conf import settings
68
from django.core.files.storage import default_storage
79
from django.core.files.uploadedfile import InMemoryUploadedFile
810

911
from ckeditor_uploader import utils
10-
from django.conf import settings
11-
12-
13-
try:
14-
from PIL import Image, ImageOps
15-
except ImportError:
16-
import Image
17-
import ImageOps
18-
1912

20-
THUMBNAIL_SIZE = getattr(settings, "THUMBNAIL_SIZE", (75,75))
2113

14+
THUMBNAIL_SIZE = getattr(settings, "THUMBNAIL_SIZE", (75, 75))
2215

2316

2417
def image_verify(f):

ckeditor_uploader/utils.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313

1414
# Non-image file icons, matched from top to bottom
1515
fileicons_path = '{0}/file-icons/'.format(getattr(settings, 'CKEDITOR_FILEICONS_PATH', '/static/ckeditor'))
16-
# This allows adding or overriding the default icons used by Gallerific by getting an additional two-tuple list from
16+
# This allows adding or overriding the default icons used by Gallerific by getting an additional two-tuple list from
1717
# the project settings. If it does not exist, it is ignored. If the same file extension exists twice, the settings
1818
# file version is used instead of the default.
1919
override_icons = getattr(settings, 'CKEDITOR_FILEICONS', [])
20-
ckeditor_icons = [
21-
('\.pdf$', fileicons_path + 'pdf.png'),
22-
('\.doc$|\.docx$|\.odt$', fileicons_path + 'doc.png'),
23-
('\.txt$', fileicons_path + 'txt.png'),
24-
('\.ppt$', fileicons_path + 'ppt.png'),
25-
('\.xls$', fileicons_path + 'xls.png'),
26-
('.*', fileicons_path + 'file.png'), # Default
27-
]
20+
ckeditor_icons = [
21+
('\.pdf$', fileicons_path + 'pdf.png'),
22+
('\.doc$|\.docx$|\.odt$', fileicons_path + 'doc.png'),
23+
('\.txt$', fileicons_path + 'txt.png'),
24+
('\.ppt$', fileicons_path + 'ppt.png'),
25+
('\.xls$', fileicons_path + 'xls.png'),
26+
('.*', fileicons_path + 'file.png'), # Default
27+
]
2828
CKEDITOR_FILEICONS = override_icons + ckeditor_icons
2929

3030

ckeditor_uploader/views.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
import os
44
from datetime import datetime
5+
from PIL import Image
56

67
from django.conf import settings
78
from django.core.files.storage import default_storage
89
from django.http import HttpResponse, JsonResponse
910
from django.shortcuts import render
10-
from django.template import RequestContext
1111
from django.views import generic
1212
from django.views.decorators.csrf import csrf_exempt
1313
from django.utils.module_loading import import_string
@@ -17,7 +17,6 @@
1717
from ckeditor_uploader import utils
1818
from ckeditor_uploader.forms import SearchForm
1919

20-
from PIL import Image
2120

2221
def get_upload_filename(upload_name, user):
2322
user_path = ''
@@ -96,7 +95,6 @@ def post(self, request, **kwargs):
9695
def _save_file(request, uploaded_file):
9796
filename = get_upload_filename(uploaded_file.name, request.user)
9897

99-
10098
img_name, img_format = os.path.splitext(filename)
10199
IMAGE_QUALITY = getattr(settings, "IMAGE_QUALITY", 60)
102100

@@ -112,11 +110,11 @@ def _save_file(request, uploaded_file):
112110
img = Image.open(uploaded_file)
113111
img = img.resize(img.size, Image.ANTIALIAS)
114112
saved_path = default_storage.save(filename, uploaded_file)
115-
img.save(saved_path,quality=IMAGE_QUALITY, optimize=True)
113+
img.save(saved_path, quality=IMAGE_QUALITY, optimize=True)
114+
116115
else:
117116
saved_path = default_storage.save(filename, uploaded_file)
118117

119-
120118
return saved_path
121119

122120
@staticmethod

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ universal = 1
88
max_line_length = 120
99

1010
[flake8]
11-
exclude = build,.git,docs,migrations,.tox
11+
exclude = build,.git,docs,migrations,.tox,venv
1212
# ignore = E123,E128,E402,E501,W503,E731,W601
1313
max-line-length = 120
1414
statistics = true

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def get_source_files():
2424
for filename in files:
2525
yield os.path.join('/'.join(dirname.split('/')[1:]), filename)
2626

27+
2728
setup(
2829
name='django-ckeditor',
2930
version=version,

0 commit comments

Comments
 (0)