diff options
-rw-r--r-- | trappy/nbexport/__init__.py | 16 | ||||
-rw-r--r-- | trappy/nbexport/exporter.py (renamed from trappy/nbexport/preprocessors.py) | 9 |
2 files changed, 15 insertions, 10 deletions
diff --git a/trappy/nbexport/__init__.py b/trappy/nbexport/__init__.py index 0293318..050a357 100644 --- a/trappy/nbexport/__init__.py +++ b/trappy/nbexport/__init__.py @@ -17,13 +17,9 @@ * Custom Preprocessing """ -from nbconvert.exporters.html import HTMLExporter -from trappy.nbexport.preprocessors import TrappyPlotterPreprocessor - - -class HTML(HTMLExporter): - """HTML Exporter class for TRAPpy notebooks""" - - def __init__(self, **kwargs): - super(HTML, self).__init__(**kwargs) - self.register_preprocessor(TrappyPlotterPreprocessor, enabled=True) +try: + from trappy.nbexport.exporter import HTML +except ImportError: + # Avoid testsuite errors when the testsuite is run in an environment without + # ipython + HTML = object diff --git a/trappy/nbexport/preprocessors.py b/trappy/nbexport/exporter.py index 096dab6..d83ca96 100644 --- a/trappy/nbexport/preprocessors.py +++ b/trappy/nbexport/exporter.py @@ -16,6 +16,7 @@ """Preprocessor to remove Marked Lines from IPython Output Cells""" +from nbconvert.exporters.html import HTMLExporter from nbconvert.preprocessors import Preprocessor import os import re @@ -27,6 +28,14 @@ IMPORT_SCRIPT = r'/\* TRAPPY_PUBLISH_IMPORT = "([^"]+)" \*/' SOURCE_LIB = r'<!-- TRAPPY_PUBLISH_SOURCE_LIB = "([^"]+)" -->' +class HTML(HTMLExporter): + """HTML Exporter class for TRAPpy notebooks""" + + def __init__(self, **kwargs): + super(HTML, self).__init__(**kwargs) + self.register_preprocessor(TrappyPlotterPreprocessor, enabled=True) + + class TrappyPlotterPreprocessor(Preprocessor): """Preprocessor to remove Marked Lines from IPython Output Cells""" |