[ci] fix linting errors

This commit is contained in:
Josh Barnes
2016-12-28 11:44:12 +00:00
parent ff17c293c1
commit 965c33460e
5 changed files with 24 additions and 18 deletions
@@ -2,13 +2,13 @@
import os
from .embedhtml import EmbedHTMLExporter
from .pp_highlighter import HighlighterPostProcessor, HighlighterPreprocessor
from .pre_codefolding import CodeFoldingPreprocessor
from .pre_collapsible_headings import CollapsibleHeadingsPreprocessor
from .pre_pymarkdown import PyMarkdownPreprocessor
from .pre_svg2pdf import SVG2PDFPreprocessor
from .toc2 import TocExporter
from .embedhtml import EmbedHTMLExporter
__all__ = [
'CodeFoldingPreprocessor',
@@ -16,8 +16,6 @@ __all__ = [
'EmbedHTMLExporter',
'HighlighterPostProcessor',
'HighlighterPreprocessor',
'LenvsHTMLExporter',
'LenvsLatexExporter',
'PyMarkdownPreprocessor',
'SVG2PDFPreprocessor',
'templates_directory',
@@ -13,17 +13,18 @@ class CodeFoldingPreprocessor(Preprocessor):
Folds codecells as displayed in the notebook.
The preprocessor is installed by default. To enable codefolding with NbConvert,
you need to set the configuration parameter `NbConvertApp.codefolding=True`.
The preprocessor is installed by default. To enable codefolding with
NbConvert, you need to set the configuration parameter
`NbConvertApp.codefolding=True`.
This can be done either in the `jupyter_nbconvert_config.py` file::
c.NbConvertApp.codefolding=True
c.NbConvertApp.codefolding = True
or using a command line parameter when calling NbConvert::
$ jupyter nbconvert --to html --NbConvertApp.codefolding=True mynotebook.ipynb
"""
""" # noqa: E501
fold_mark = u''
@@ -68,8 +69,8 @@ class CodeFoldingPreprocessor(Preprocessor):
index : int
Index of the cell being processed (see base.py)
"""
dofolding = self.config.NbConvertApp.get('codefolding', False)
if hasattr(cell, "source") and cell.cell_type == "code" and dofolding is True:
dofolding = self.config.NbConvertApp.get('codefolding', False) is True
if hasattr(cell, 'source') and cell.cell_type == 'code' and dofolding:
if hasattr(cell['metadata'], 'code_folding'):
folded = cell['metadata']['code_folding']
if len(folded) > 0:
@@ -64,13 +64,17 @@ class SVG2PDFPreprocessor(Preprocessor):
Because LaTeX can't use SVG graphics, they are converted to PDF using
inkscape_. This preprocessor is for SVG graphics in markdown only. For SVG
outputs from codecells, there is already the built-in nbconvert preprocessor
outputs from codecells, there is already the built-in nbconvert
preprocessor.
Configuration::
c.Exporter.preprocessors = [ "jupyter_contrib_nbextensions.nbconvert_support.SVG2PDFPreprocessor" ]
c.Exporter.preprocessors.append(
"jupyter_contrib_nbextensions.nbconvert_support.SVG2PDFPreprocessor"
)
.. _inkscape: https://inkscape.org/en
"""
""" # noqa: E501
def _from_format_default(self):
return 'image/svg+xml'
+3 -2
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
"""Tests for custom exporters."""
from nbconvert.tests.base import TestsBase
from nbformat import v4, write
import io
import os
from nbconvert.tests.base import TestsBase
from nbformat import v4, write
def path_in_data(rel_path):
"""Return an absolute path from a relative path in tests/data."""
+6 -4
View File
@@ -16,9 +16,10 @@ def path_in_data(rel_path):
def export_through_preprocessor(
notebook_node, preproc_cls, exporter_class, export_format, customconfig=None):
notebook_node, preproc_cls, exporter_class, export_format,
customconfig=None):
"""Export a notebook through a given preprocessor."""
config=Config(NbConvertApp={'export_format': export_format })
config = Config(NbConvertApp={'export_format': export_format})
if customconfig is not None:
config.merge(customconfig)
exporter = exporter_class(
@@ -58,9 +59,10 @@ def test_preprocessor_codefolding():
" 'GR4CX32ZT'"]),
metadata={"code_folding": [1]}),
])
customconfig = Config(NbConvertApp={'codefolding' : True})
customconfig = Config(NbConvertApp={'codefolding': True})
body, resources = export_through_preprocessor(
notebook_node, CodeFoldingPreprocessor, RSTExporter, 'rst', customconfig)
notebook_node, CodeFoldingPreprocessor, RSTExporter, 'rst',
customconfig)
assert_not_in('AXYZ12AXY', body, 'check firstline fold has worked')
assert_not_in('GR4CX32ZT', body, 'check function fold has worked')