|
@@
-33,7
+33,7
b' from IPython.utils.importstring import import_item'
|
|
33
|
from IPython.utils.text import dedent
|
|
33
|
from IPython.utils.text import dedent
|
|
34
|
|
|
34
|
|
|
35
|
from .exporters.export import get_export_names, exporter_map
|
|
35
|
from .exporters.export import get_export_names, exporter_map
|
|
36
|
from IPython.nbconvert import exporters, preprocessors, writers, post_processors
|
|
36
|
from IPython.nbconvert import exporters, preprocessors, writers, postprocessors
|
|
37
|
from .utils.base import NbConvertBase
|
|
37
|
from .utils.base import NbConvertBase
|
|
38
|
from .utils.exceptions import ConversionException
|
|
38
|
from .utils.exceptions import ConversionException
|
|
39
|
|
|
39
|
|
|
@@
-60,7
+60,7
b' nbconvert_aliases.update({'
|
|
60
|
'to' : 'NbConvertApp.export_format',
|
|
60
|
'to' : 'NbConvertApp.export_format',
|
|
61
|
'template' : 'Exporter.template_file',
|
|
61
|
'template' : 'Exporter.template_file',
|
|
62
|
'writer' : 'NbConvertApp.writer_class',
|
|
62
|
'writer' : 'NbConvertApp.writer_class',
|
|
63
|
'post': 'NbConvertApp.post_processor_class',
|
|
63
|
'post': 'NbConvertApp.postprocessor_class',
|
|
64
|
'output': 'NbConvertApp.output_base',
|
|
64
|
'output': 'NbConvertApp.output_base',
|
|
65
|
'offline-slides': 'RevealHelpTransformer.url_prefix',
|
|
65
|
'offline-slides': 'RevealHelpTransformer.url_prefix',
|
|
66
|
'slide-notes': 'RevealHelpTransformer.speaker_notes'
|
|
66
|
'slide-notes': 'RevealHelpTransformer.speaker_notes'
|
|
@@
-166,22
+166,22
b' class NbConvertApp(BaseIPythonApplication):'
|
|
166
|
self.writer_factory = import_item(new)
|
|
166
|
self.writer_factory = import_item(new)
|
|
167
|
|
|
167
|
|
|
168
|
# Post-processor specific variables
|
|
168
|
# Post-processor specific variables
|
|
169
|
post_processor = Instance('IPython.nbconvert.post_processors.base.PostProcessorBase',
|
|
169
|
postprocessor = Instance('IPython.nbconvert.postprocessors.base.PostProcessorBase',
|
|
170
|
help="""Instance of the PostProcessor class used to write the
|
|
170
|
help="""Instance of the PostProcessor class used to write the
|
|
171
|
results of the conversion.""")
|
|
171
|
results of the conversion.""")
|
|
172
|
|
|
172
|
|
|
173
|
post_processor_class = DottedOrNone(config=True,
|
|
173
|
postprocessor_class = DottedOrNone(config=True,
|
|
174
|
help="""PostProcessor class used to write the
|
|
174
|
help="""PostProcessor class used to write the
|
|
175
|
results of the conversion""")
|
|
175
|
results of the conversion""")
|
|
176
|
post_processor_aliases = {'pdf': 'IPython.nbconvert.post_processors.pdf.PDFPostProcessor',
|
|
176
|
postprocessor_aliases = {'pdf': 'IPython.nbconvert.postprocessors.pdf.PDFPostProcessor',
|
|
177
|
'serve': 'IPython.nbconvert.post_processors.serve.ServePostProcessor'}
|
|
177
|
'serve': 'IPython.nbconvert.postprocessors.serve.ServePostProcessor'}
|
|
178
|
post_processor_factory = Type()
|
|
178
|
postprocessor_factory = Type()
|
|
179
|
|
|
179
|
|
|
180
|
def _post_processor_class_changed(self, name, old, new):
|
|
180
|
def _postprocessor_class_changed(self, name, old, new):
|
|
181
|
if new.lower() in self.post_processor_aliases:
|
|
181
|
if new.lower() in self.postprocessor_aliases:
|
|
182
|
new = self.post_processor_aliases[new.lower()]
|
|
182
|
new = self.postprocessor_aliases[new.lower()]
|
|
183
|
if new:
|
|
183
|
if new:
|
|
184
|
self.post_processor_factory = import_item(new)
|
|
184
|
self.postprocessor_factory = import_item(new)
|
|
185
|
|
|
185
|
|
|
186
|
|
|
186
|
|
|
187
|
# Other configurable variables
|
|
187
|
# Other configurable variables
|
|
@@
-202,7
+202,7
b' class NbConvertApp(BaseIPythonApplication):'
|
|
202
|
self.init_syspath()
|
|
202
|
self.init_syspath()
|
|
203
|
self.init_notebooks()
|
|
203
|
self.init_notebooks()
|
|
204
|
self.init_writer()
|
|
204
|
self.init_writer()
|
|
205
|
self.init_post_processor()
|
|
205
|
self.init_postprocessor()
|
|
206
|
|
|
206
|
|
|
207
|
|
|
207
|
|
|
208
|
|
|
208
|
|
|
@@
-250,14
+250,14
b' class NbConvertApp(BaseIPythonApplication):'
|
|
250
|
self._writer_class_changed(None, self.writer_class, self.writer_class)
|
|
250
|
self._writer_class_changed(None, self.writer_class, self.writer_class)
|
|
251
|
self.writer = self.writer_factory(parent=self)
|
|
251
|
self.writer = self.writer_factory(parent=self)
|
|
252
|
|
|
252
|
|
|
253
|
def init_post_processor(self):
|
|
253
|
def init_postprocessor(self):
|
|
254
|
"""
|
|
254
|
"""
|
|
255
|
Initialize the post_processor (which is stateless)
|
|
255
|
Initialize the postprocessor (which is stateless)
|
|
256
|
"""
|
|
256
|
"""
|
|
257
|
self._post_processor_class_changed(None, self.post_processor_class,
|
|
257
|
self._postprocessor_class_changed(None, self.postprocessor_class,
|
|
258
|
self.post_processor_class)
|
|
258
|
self.postprocessor_class)
|
|
259
|
if self.post_processor_factory:
|
|
259
|
if self.postprocessor_factory:
|
|
260
|
self.post_processor = self.post_processor_factory(parent=self)
|
|
260
|
self.postprocessor = self.postprocessor_factory(parent=self)
|
|
261
|
|
|
261
|
|
|
262
|
def start(self):
|
|
262
|
def start(self):
|
|
263
|
"""
|
|
263
|
"""
|
|
@@
-306,8
+306,8
b' class NbConvertApp(BaseIPythonApplication):'
|
|
306
|
write_resultes = self.writer.write(output, resources, notebook_name=notebook_name)
|
|
306
|
write_resultes = self.writer.write(output, resources, notebook_name=notebook_name)
|
|
307
|
|
|
307
|
|
|
308
|
#Post-process if post processor has been defined.
|
|
308
|
#Post-process if post processor has been defined.
|
|
309
|
if hasattr(self, 'post_processor') and self.post_processor:
|
|
309
|
if hasattr(self, 'postprocessor') and self.postprocessor:
|
|
310
|
self.post_processor(write_resultes)
|
|
310
|
self.postprocessor(write_resultes)
|
|
311
|
conversion_success += 1
|
|
311
|
conversion_success += 1
|
|
312
|
|
|
312
|
|
|
313
|
# If nothing was converted successfully, help the user.
|
|
313
|
# If nothing was converted successfully, help the user.
|