Show More
@@ -32,7 +32,7 b' from IPython.utils.traitlets import (' | |||||
32 | from IPython.utils.importstring import import_item |
|
32 | 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 |
|
35 | from .exporters.export import get_export_names, exporter_map | |
36 | from IPython.nbconvert import exporters, transformers, writers, post_processors |
|
36 | from IPython.nbconvert import exporters, transformers, writers, post_processors | |
37 | from .utils.base import NbConvertBase |
|
37 | from .utils.base import NbConvertBase | |
38 | from .utils.exceptions import ConversionException |
|
38 | from .utils.exceptions import ConversionException | |
@@ -273,11 +273,13 b' class NbConvertApp(BaseIPythonApplication):' | |||||
273 | conversion_success = 0 |
|
273 | conversion_success = 0 | |
274 |
|
274 | |||
275 | if self.output_base != '' and len(self.notebooks) > 1: |
|
275 | if self.output_base != '' and len(self.notebooks) > 1: | |
276 | print(dedent( |
|
276 | self.log.error( | |
277 | """UsageError: --output flag or `NbConvertApp.output_base` config option |
|
277 | """UsageError: --output flag or `NbConvertApp.output_base` config option | |
278 | cannot be used when converting multiple notebooks. |
|
278 | cannot be used when converting multiple notebooks. | |
279 |
""") |
|
279 | """) | |
280 | self.exit(1) |
|
280 | self.exit(1) | |
|
281 | ||||
|
282 | exporter = exporter_map[self.export_format](config=self.config) | |||
281 |
|
283 | |||
282 | for notebook_filename in self.notebooks: |
|
284 | for notebook_filename in self.notebooks: | |
283 | self.log.info("Converting notebook %s to %s", notebook_filename, self.export_format) |
|
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 | # Try to export |
|
297 | # Try to export | |
296 | try: |
|
298 | try: | |
297 |
output, resources = export |
|
299 | output, resources = exporter.from_filename(notebook_filename, resources=resources) | |
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) |
|
|||
309 | except ConversionException as e: |
|
300 | except ConversionException as e: | |
310 |
|
|
301 | self.log.error("Error while converting '%s'", notebook_filename, | |
311 |
|
|
302 | exc_info=True) | |
312 | self.exit(1) |
|
303 | self.exit(1) | |
313 | else: |
|
304 | else: | |
314 | write_resultes = self.writer.write(output, resources, notebook_name=notebook_name) |
|
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