From 965c33460e739c0a01d64dc42f00a05c4a9beecb Mon Sep 17 00:00:00 2001 From: Josh Barnes Date: Wed, 28 Dec 2016 11:39:00 +0000 Subject: [PATCH] [ci] fix linting errors --- .../nbconvert_support/__init__.py | 4 +--- .../nbconvert_support/pre_codefolding.py | 13 +++++++------ .../nbconvert_support/pre_svg2pdf.py | 10 +++++++--- tests/test_exporters.py | 5 +++-- tests/test_preprocessors.py | 10 ++++++---- 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/jupyter_contrib_nbextensions/nbconvert_support/__init__.py b/src/jupyter_contrib_nbextensions/nbconvert_support/__init__.py index b1ea269..3b02b56 100644 --- a/src/jupyter_contrib_nbextensions/nbconvert_support/__init__.py +++ b/src/jupyter_contrib_nbextensions/nbconvert_support/__init__.py @@ -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', diff --git a/src/jupyter_contrib_nbextensions/nbconvert_support/pre_codefolding.py b/src/jupyter_contrib_nbextensions/nbconvert_support/pre_codefolding.py index 8707c0c..3d19ef8 100644 --- a/src/jupyter_contrib_nbextensions/nbconvert_support/pre_codefolding.py +++ b/src/jupyter_contrib_nbextensions/nbconvert_support/pre_codefolding.py @@ -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: diff --git a/src/jupyter_contrib_nbextensions/nbconvert_support/pre_svg2pdf.py b/src/jupyter_contrib_nbextensions/nbconvert_support/pre_svg2pdf.py index 9ca5376..7998631 100644 --- a/src/jupyter_contrib_nbextensions/nbconvert_support/pre_svg2pdf.py +++ b/src/jupyter_contrib_nbextensions/nbconvert_support/pre_svg2pdf.py @@ -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' diff --git a/tests/test_exporters.py b/tests/test_exporters.py index bf694f9..d939de4 100644 --- a/tests/test_exporters.py +++ b/tests/test_exporters.py @@ -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.""" diff --git a/tests/test_preprocessors.py b/tests/test_preprocessors.py index 0feac4c..3e52145 100644 --- a/tests/test_preprocessors.py +++ b/tests/test_preprocessors.py @@ -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')