Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
PEP8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sv0 committed Nov 10, 2018
1 parent 5820c4f commit dc51f79
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 21 deletions.
31 changes: 21 additions & 10 deletions django_markdown/pypandoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,26 @@
def convert(source, to, format=None, extra_args=(), encoding='utf-8'):
"""Convert given `source` from `format` `to` another.
`source` may be either a file path or a string to be converted. It's possible to pass
`extra_args` if needed. In case `format` is not provided, it will try to invert the format
based on given `source`.
`source` may be either a file path or a string to be converted.
It's possible to pass `extra_args` if needed. In case `format` is not
provided, it will try to invert the format based on given `source`.
Raises OSError if pandoc is not found! Make sure it has been installed and is available at
path.
Raises OSError if pandoc is not found! Make sure it has been installed and
is available at path.
"""
return _convert(_read_file, _process_file, source, to, format, extra_args, encoding=encoding)


def _convert(reader, processor, source, to, format=None, extra_args=(), encoding=None):
return _convert(
_read_file, _process_file,
source, to,
format, extra_args,
encoding=encoding)


def _convert(
reader, processor,
source, to,
format=None, extra_args=(),
encoding=None):
source, format = reader(source, format, encoding=encoding)

formats = {
Expand All @@ -48,7 +56,10 @@ def _convert(reader, processor, source, to, format=None, extra_args=(), encoding
', '.join(from_formats))

if to not in to_formats:
raise RuntimeError('Invalid to format! Expected one of these: ' + ', '.join(to_formats))
raise RuntimeError(
'Invalid to format! Expected one of these: '
+ ', '.join(to_formats)
)

return processor(source, to, format, extra_args)

Expand Down
18 changes: 14 additions & 4 deletions django_markdown/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,29 @@


MARKDOWN_EDITOR_INIT_TEMPLATE = getattr(
settings, 'MARKDOWN_EDITOR_INIT_TEMPLATE', 'django_markdown/editor_init.html')
settings,
'MARKDOWN_EDITOR_INIT_TEMPLATE',
'django_markdown/editor_init.html'
)
MARKDOWN_EDITOR_SETTINGS = getattr(settings, 'MARKDOWN_EDITOR_SETTINGS', {})
MARKDOWN_EDITOR_SKIN = getattr(settings, 'MARKDOWN_EDITOR_SKIN', 'simple')
MARKDOWN_EXTENSIONS = getattr(settings, 'MARKDOWN_EXTENSIONS', [])
MARKDOWN_EXTENSION_CONFIGS = getattr(settings, 'MARKDOWN_EXTENSION_CONFIGS', {})
MARKDOWN_SET_PATH = getattr(settings, 'MARKDOWN_SET_PATH', 'django_markdown/sets')
MARKDOWN_EXTENSION_CONFIGS = getattr(
settings, 'MARKDOWN_EXTENSION_CONFIGS', {}
)
MARKDOWN_SET_PATH = getattr(
settings, 'MARKDOWN_SET_PATH', 'django_markdown/sets')

MARKDOWN_SET_NAME = getattr(
settings, 'MARKDOWN_SET_NAME',
'markdownextra' if 'extra' in MARKDOWN_EXTENSIONS else 'markdown')

MARKDOWN_PREVIEW_TEMPLATE = getattr(
settings, 'MARKDOWN_PREVIEW_TEMPLATE', 'django_markdown/preview.html')
MARKDOWN_STYLE = getattr(settings, 'MARKDOWN_STYLE', 'django_markdown/preview.css')

MARKDOWN_STYLE = getattr(
settings, 'MARKDOWN_STYLE', 'django_markdown/preview.css')

MARKDOWN_PROTECT_PREVIEW = getattr(settings, 'MARKDOWN_PROTECT_PREVIEW', False)

LOGIN_URL = settings.LOGIN_URL
2 changes: 1 addition & 1 deletion django_markdown/templatetags/django_markdown_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
register = Library()

if 'django.contrib.staticfiles' in settings.INSTALLED_APPS:
from django.contrib.staticfiles.templatetags.staticfiles import static as _static
from django.contrib.staticfiles.templatetags.staticfiles import static as _static # noqa
else:
from django.templatetags.static import static as _static

Expand Down
14 changes: 10 additions & 4 deletions django_markdown/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.test import TestCase

from django_markdown.utils import markdown as markdown_util
from django_markdown.templatetags.django_markdown import markdown as markdown_tag
from django_markdown.templatetags.django_markdown import markdown as markdown_tag # noqa
from django_markdown.widgets import MarkdownWidget


Expand All @@ -18,7 +18,8 @@ def test_markdown_tag(self):

expected = ('<table>\n<thead>\n<tr>\n<th>header 1</th>\n'
'<th>header 2</th>\n</tr>\n</thead>\n<tbody>\n'
'<tr>\n<td>data</td>\n<td>data</td>\n</tr>\n</tbody>\n</table>')
'<tr>\n<td>data</td>\n<td>data</td>\n</tr>\n</tbody>\n'
'</table>')
self.assertEqual(html, expected)


Expand Down Expand Up @@ -95,9 +96,14 @@ def test_markdown_widget(self):
"""test MarkdownWidget.render"""

form = forms.Form()
form.fields['test_field'] = forms.CharField(label='test', widget=MarkdownWidget)
form.fields['test_field'] = forms.CharField(
label='test',
widget=MarkdownWidget
)

template = Template('{% load django_markdown %}<html>{{ form }}</html>')
template = Template(
'{% load django_markdown %}<html>{{ form }}</html>'
)
context = Context({'form': form})
html = template.render(context)

Expand Down
6 changes: 4 additions & 2 deletions django_markdown/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ class Media:
'screen': (
os.path.join('django_markdown', 'skins',
settings.MARKDOWN_EDITOR_SKIN, 'style.css'),
os.path.join(settings.MARKDOWN_SET_PATH, settings.MARKDOWN_SET_NAME, 'style.css')
os.path.join(settings.MARKDOWN_SET_PATH,
settings.MARKDOWN_SET_NAME, 'style.css')
)
}

js = (
os.path.join('django_markdown', 'jquery.init.js'),
os.path.join('django_markdown', 'jquery.markitup.js'),
os.path.join(settings.MARKDOWN_SET_PATH, settings.MARKDOWN_SET_NAME, 'set.js'),
os.path.join(settings.MARKDOWN_SET_PATH,
settings.MARKDOWN_SET_NAME, 'set.js'),
os.path.join('django_markdown', 'editor.js')
)

Expand Down

0 comments on commit dc51f79

Please sign in to comment.