##// END OF EJS Templates
create single exporter in NotebookApp...
MinRK -
Show More
@@ -32,7 +32,7 b' from IPython.utils.traitlets import ('
32 32 from IPython.utils.importstring import import_item
33 33 from IPython.utils.text import dedent
34 34
35 from .exporters.export import export_by_name, get_export_names, ExporterNameError
35 from .exporters.export import get_export_names, exporter_map
36 36 from IPython.nbconvert import exporters, transformers, writers, post_processors
37 37 from .utils.base import NbConvertBase
38 38 from .utils.exceptions import ConversionException
@@ -273,11 +273,13 b' class NbConvertApp(BaseIPythonApplication):'
273 273 conversion_success = 0
274 274
275 275 if self.output_base != '' and len(self.notebooks) > 1:
276 print(dedent(
276 self.log.error(
277 277 """UsageError: --output flag or `NbConvertApp.output_base` config option
278 278 cannot be used when converting multiple notebooks.
279 """))
279 """)
280 280 self.exit(1)
281
282 exporter = exporter_map[self.export_format](config=self.config)
281 283
282 284 for notebook_filename in self.notebooks:
283 285 self.log.info("Converting notebook %s to %s", notebook_filename, self.export_format)
@@ -294,21 +296,10 b' class NbConvertApp(BaseIPythonApplication):'
294 296
295 297 # Try to export
296 298 try:
297 output, resources = export_by_name(self.export_format,
298 notebook_filename,
299 resources=resources,
300 config=self.config)
301 except ExporterNameError as e:
302 print("Error while converting '%s': '%s' exporter not found."
303 %(notebook_filename, self.export_format),
304 file=sys.stderr)
305 print("Known exporters are:",
306 "\n\t" + "\n\t".join(get_export_names()),
307 file=sys.stderr)
308 self.exit(1)
299 output, resources = exporter.from_filename(notebook_filename, resources=resources)
309 300 except ConversionException as e:
310 print("Error while converting '%s': %s" %(notebook_filename, e),
311 file=sys.stderr)
301 self.log.error("Error while converting '%s'", notebook_filename,
302 exc_info=True)
312 303 self.exit(1)
313 304 else:
314 305 write_resultes = self.writer.write(output, resources, notebook_name=notebook_name)
General Comments 0
You need to be logged in to leave comments. Login now