Skip to content

Commit

Permalink
Fix flake8, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
greyli committed May 29, 2018
1 parent bd23a0b commit a266208
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 26 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ language: python

python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
Expand Down
36 changes: 17 additions & 19 deletions flask_ckeditor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from functools import wraps
from flask import current_app, Markup, Blueprint, url_for, request, jsonify

from flask_ckeditor.fields import CKEditorField
from flask_ckeditor.utils import get_url, random_filename
from flask_ckeditor.fields import CKEditorField # noqa
from flask_ckeditor.utils import get_url, random_filename # noqa


class _CKEditor(object):
Expand All @@ -16,7 +16,7 @@ def load(custom_url=None, pkg_type=None, version='4.9.2'):
:param custom_url: The custom resource url to use, build your CKEditor
on `CKEditor builder <https://ckeditor.com/cke4/builder>`_.
:param pkg_type: The type of CKEditor package, one of ``basic``,
:param pkg_type: The type of CKEditor package, one of ``basic``,
``standard`` and ``full``. Default to ``standard``.
:param version: The version of CKEditor.
"""
Expand All @@ -42,13 +42,12 @@ def config(name='ckeditor', language=None, height=None, width=None, code_theme=N
"""Config CKEditor.
:param name: The target input field's name. If you use Flask-WTF/WTForms, it need to set
to field's name. Default to 'ckeditor'.
to field's name. Default to 'ckeditor'.
:param language: The lang code string to set UI language in ISO 639 format, for example:
``zh``, ``zh-cn``, ``ko``, ``ja``, ``es``, ``fr``, ``de``, ``en`` etc, default to ``en``(i.e. English).
:param height: The height of CKEditor window, default to 200.
:param width: The width of CKEditor window.
:param code_theme: The theme's name in string used for code snippets, default to
``monokai_sublime``.
:param code_theme: The theme's name in string used for code snippets, default to ``monokai_sublime``.
:param file_uploader: The url or endpoint to send the upload data. The related view function
should return the ``upload_success()`` or ``upload_fail()`` call.
Check ``examples/image-upload/app.py`` for more detail.
Expand All @@ -71,12 +70,11 @@ def config(name='ckeditor', language=None, height=None, width=None, code_theme=N

if file_uploader != '':
file_uploader = get_url(file_uploader)
if 'filebrowser' not in extra_plugins:
extra_plugins.append('filebrowser')
if file_browser != '':
file_browser = get_url(file_browser)
if 'filebrowser' not in extra_plugins:
extra_plugins.append('filebrowser')

if file_uploader or file_browser and 'filebrowser' not in extra_plugins:
extra_plugins.append('filebrowser')

language = language or current_app.config['CKEDITOR_LANGUAGE']
height = height or current_app.config['CKEDITOR_HEIGHT']
Expand Down Expand Up @@ -112,11 +110,11 @@ def config(name='ckeditor', language=None, height=None, width=None, code_theme=N
@staticmethod
def create(name='ckeditor', value=''):
"""Create a ckeditor textarea directly.
:param name: The name attribute of CKEditor textarea, set it when you need to create
more than one textarea in one page. Default to `ckeditor`.
:param value: The preset value for textarea.
.. versionadded:: 0.3
"""
return Markup('<textarea class="ckeditor" name="%s">%s</textarea>' % (name, value))
Expand Down Expand Up @@ -163,14 +161,14 @@ def init_app(self, app):
app.config.setdefault('CKEDITOR_FILE_BROWSER', '')

# Default error message for upload fail
# .. versionadded:: 0.3.5
# .. versionadded:: 0.4.0
app.config.setdefault('CKEDITOR_UPLOAD_ERROR_MESSAGE', 'Upload failed.')

# Enable Markdown mode
# .. versionadded:: 0.3.4
app.config.setdefault('CKEDITOR_ENABLE_MARKDOWN', False)
# Enable Code Snippet plugin
# .. versionadded:: 0.3.5
# .. versionadded:: 0.4.0
app.config.setdefault('CKEDITOR_ENABLE_CODESNIPPET', False)

# Register extra CKEditor plugins
Expand All @@ -188,7 +186,7 @@ def uploader(func):
Decorated the view function that handle the file upload. The upload
view must return the uploaded image's url. For example::
from flask import send_from_directory
@app.route('/files/<filename>')
Expand All @@ -210,9 +208,9 @@ def upload():
@wraps(func)
def wrapper(*args, **kwargs):
func_num = request.args.get('CKEditorFuncNum')
ckeditor = request.args.get('CKEditor')
# ckeditor = request.args.get('CKEditor')
# language code used for error message, not used yet.
lang_code = request.args.get('langCode')
# lang_code = request.args.get('langCode')
# the error message to display when upload failed.
message = current_app.config['CKEDITOR_UPLOAD_ERROR_MESSAGE']
url = func(*args, **kwargs)
Expand Down Expand Up @@ -246,7 +244,7 @@ def upload():
.. versionadded:: 0.3.5
.. versionadded:: 0.4.0
"""
return jsonify(uploaded=1, url=url, filename=filename)

Expand Down Expand Up @@ -274,7 +272,7 @@ def upload():
:param message: error message.
.. versionadded:: 0.3.5
.. versionadded:: 0.4.0
"""
if message is None:
message = current_app.config['CKEDITOR_UPLOAD_ERROR_MESSAGE']
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ universal=1
[flake8]
exclude = static
max-line-length = 119
max-complexity = 5
max-complexity = 7
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Config CKEditor through Flask's configuration system.
* Image upload support.
* Code snippet highlight.
* Bulit-in CKEditor resources.
* Built-in CKEditor resources.
Go to `Github page
<https://github.com/greyli/flask-ckeditor>`_ , which you can check for more
Expand All @@ -26,7 +26,7 @@

setup(
name='Flask-CKEditor',
version='0.3.4',
version='0.4',
url='http://github.com/greyli/flask-ckeditor',
license='MIT',
author='Grey Li',
Expand All @@ -51,7 +51,6 @@
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
Expand Down
2 changes: 1 addition & 1 deletion test_flask_ckeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def setUp(self):
self.app.secret_key = 'for test'
self.app.config['WTF_ENABLE_CSRF'] = False

ckeditor = CKEditor(self.app)
ckeditor = CKEditor(self.app) # noqa

self.ckeditor = _CKEditor

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27, py36
envlist = py27, py34, py35, py36
skip_missing_interpreters = true
skipsdist = true

Expand Down

0 comments on commit a266208

Please sign in to comment.