From 19cf30d41af7683c2fe6b7ed34ba87a49329aa73 2013-09-12 15:33:57 From: Matthias BUSSONNIER Date: 2013-09-12 15:33:57 Subject: [PATCH] Exporter -> TemplateExporter / BaseExporter --- diff --git a/IPython/nbconvert/exporters/__init__.py b/IPython/nbconvert/exporters/__init__.py index 25dd322..9b4bc6f 100644 --- a/IPython/nbconvert/exporters/__init__.py +++ b/IPython/nbconvert/exporters/__init__.py @@ -1,7 +1,7 @@ from .export import * from .html import HTMLExporter from .slides import SlidesExporter -from .exporter import Exporter +from .exporter import TemplateExporter from .latex import LatexExporter from .markdown import MarkdownExporter from .python import PythonExporter diff --git a/IPython/nbconvert/exporters/baseexporter.py b/IPython/nbconvert/exporters/baseexporter.py index 9427212..065ab99 100644 --- a/IPython/nbconvert/exporters/baseexporter.py +++ b/IPython/nbconvert/exporters/baseexporter.py @@ -1,4 +1,4 @@ -"""This module defines Exporter, a highly configurable converter +"""This module defines BaseExporter, a highly configurable converter that uses Jinja2 to export notebook files into different formats. """ diff --git a/IPython/nbconvert/exporters/export.py b/IPython/nbconvert/exporters/export.py index 31820e4..a8ab83f 100644 --- a/IPython/nbconvert/exporters/export.py +++ b/IPython/nbconvert/exporters/export.py @@ -18,7 +18,7 @@ from functools import wraps from IPython.nbformat.v3.nbbase import NotebookNode from IPython.config import Config -from .exporter import Exporter +from .exporter import TemplateExporter from .html import HTMLExporter from .slides import SlidesExporter from .latex import LatexExporter @@ -100,14 +100,14 @@ def export(exporter, nb, **kw): #Check arguments if exporter is None: raise TypeError("Exporter is None") - elif not isinstance(exporter, Exporter) and not issubclass(exporter, Exporter): + elif not isinstance(exporter, TemplateExporter) and not issubclass(exporter, TemplateExporter): raise TypeError("exporter does not inherit from Exporter (base)") if nb is None: raise TypeError("nb is None") #Create the exporter resources = kw.pop('resources', None) - if isinstance(exporter, Exporter): + if isinstance(exporter, TemplateExporter): exporter_instance = exporter else: exporter_instance = exporter(**kw) @@ -122,7 +122,7 @@ def export(exporter, nb, **kw): return output, resources exporter_map = dict( - custom=Exporter, + custom=TemplateExporter, html=HTMLExporter, slides=SlidesExporter, latex=LatexExporter, diff --git a/IPython/nbconvert/exporters/html.py b/IPython/nbconvert/exporters/html.py index 6e1b18f..4e63599 100644 --- a/IPython/nbconvert/exporters/html.py +++ b/IPython/nbconvert/exporters/html.py @@ -19,13 +19,13 @@ from IPython.utils.traitlets import Unicode, List from IPython.nbconvert import preprocessors from IPython.config import Config -from .exporter import Exporter +from .exporter import TemplateExporter #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- -class HTMLExporter(Exporter): +class HTMLExporter(TemplateExporter): """ Exports a basic HTML document. This exporter assists with the export of HTML. Inherit from it if you are writing your own HTML template and need diff --git a/IPython/nbconvert/exporters/markdown.py b/IPython/nbconvert/exporters/markdown.py index 5bce932..5366609 100644 --- a/IPython/nbconvert/exporters/markdown.py +++ b/IPython/nbconvert/exporters/markdown.py @@ -16,13 +16,13 @@ Exporter that will export your ipynb to Markdown. from IPython.config import Config from IPython.utils.traitlets import Unicode -from .exporter import Exporter +from .exporter import TemplateExporter #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- -class MarkdownExporter(Exporter): +class MarkdownExporter(TemplateExporter): """ Exports to a markdown document (.md) """ diff --git a/IPython/nbconvert/exporters/python.py b/IPython/nbconvert/exporters/python.py index 9fe2a94..9d6fdbd 100644 --- a/IPython/nbconvert/exporters/python.py +++ b/IPython/nbconvert/exporters/python.py @@ -15,13 +15,13 @@ Python exporter which exports Notebook code into a PY file. from IPython.utils.traitlets import Unicode -from .exporter import Exporter +from .exporter import TemplateExporter #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- -class PythonExporter(Exporter): +class PythonExporter(TemplateExporter): """ Exports a Python code file. """ diff --git a/IPython/nbconvert/exporters/rst.py b/IPython/nbconvert/exporters/rst.py index d22c6af..540e11f 100644 --- a/IPython/nbconvert/exporters/rst.py +++ b/IPython/nbconvert/exporters/rst.py @@ -16,13 +16,13 @@ Exporter for exporting notebooks to restructured text. from IPython.utils.traitlets import Unicode from IPython.config import Config -from .exporter import Exporter +from .exporter import TemplateExporter #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- -class RSTExporter(Exporter): +class RSTExporter(TemplateExporter): """ Exports restructured text documents. """ diff --git a/IPython/nbconvert/exporters/slides.py b/IPython/nbconvert/exporters/slides.py index 9920206..f22c1ae 100644 --- a/IPython/nbconvert/exporters/slides.py +++ b/IPython/nbconvert/exporters/slides.py @@ -19,13 +19,13 @@ from IPython.utils.traitlets import Unicode from IPython.nbconvert import preprocessors from IPython.config import Config -from .exporter import Exporter +from .exporter import TemplateExporter #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- -class SlidesExporter(Exporter): +class SlidesExporter(TemplateExporter): """ Exports slides """ diff --git a/IPython/nbconvert/exporters/tests/base.py b/IPython/nbconvert/exporters/tests/base.py index 5501b8c..18ae21d 100644 --- a/IPython/nbconvert/exporters/tests/base.py +++ b/IPython/nbconvert/exporters/tests/base.py @@ -27,4 +27,4 @@ class ExportersTestsBase(TestsBase): def _get_notebook(self): return os.path.join(self._get_files_path(), 'notebook2.ipynb') - \ No newline at end of file + diff --git a/IPython/nbconvert/exporters/tests/test_export.py b/IPython/nbconvert/exporters/tests/test_export.py index 96e02fa..ccf7de5 100644 --- a/IPython/nbconvert/exporters/tests/test_export.py +++ b/IPython/nbconvert/exporters/tests/test_export.py @@ -99,4 +99,4 @@ class TestExport(ExportersTestsBase): (output, resources) = export(None, self._get_notebook()) except TypeError: pass - \ No newline at end of file + diff --git a/IPython/nbconvert/nbconvertapp.py b/IPython/nbconvert/nbconvertapp.py index 08bc0b8..4e205b9 100755 --- a/IPython/nbconvert/nbconvertapp.py +++ b/IPython/nbconvert/nbconvertapp.py @@ -59,7 +59,7 @@ nbconvert_aliases = {} nbconvert_aliases.update(base_aliases) nbconvert_aliases.update({ 'to' : 'NbConvertApp.export_format', - 'template' : 'Exporter.template_file', + 'template' : 'TemplateExporter.template_file', 'writer' : 'NbConvertApp.writer_class', 'post': 'NbConvertApp.postprocessor_class', 'output': 'NbConvertApp.output_base',