Show More
@@ -86,7 +86,8 b' __all__ = [' | |||||
86 | 'export_python_armor', |
|
86 | 'export_python_armor', | |
87 | 'export_reveal', |
|
87 | 'export_reveal', | |
88 | 'export_rst', |
|
88 | 'export_rst', | |
89 | 'export_by_name' |
|
89 | 'export_by_name', | |
|
90 | 'get_export_names' | |||
90 | ] |
|
91 | ] | |
91 |
|
92 | |||
92 | @DocDecorator |
|
93 | @DocDecorator | |
@@ -223,3 +224,10 b' def export_by_name(template_name, nb, config=None, transformers=None, filters=No' | |||||
223 | else: |
|
224 | else: | |
224 | raise NameError("template for `%s` not found" % function_name) |
|
225 | raise NameError("template for `%s` not found" % function_name) | |
225 |
|
226 | |||
|
227 | def get_export_names(): | |||
|
228 | "Return a list of the currently supported export targets" | |||
|
229 | # grab everything after 'export_' | |||
|
230 | l = [x[len('export_'):] for x in __all__ if x.startswith('export_')] | |||
|
231 | # filter out the one method that is not a template | |||
|
232 | l = [x for x in l if 'by_name' not in x] | |||
|
233 | return sorted(l) |
@@ -26,7 +26,7 b' import os' | |||||
26 | from IPython.config.application import Application |
|
26 | from IPython.config.application import Application | |
27 | from IPython.utils.traitlets import Bool, Unicode |
|
27 | from IPython.utils.traitlets import Bool, Unicode | |
28 |
|
28 | |||
29 | from .exporters.export import export_by_name |
|
29 | from .exporters.export import export_by_name, get_export_names | |
30 | from .exporters.exporter import Exporter |
|
30 | from .exporters.exporter import Exporter | |
31 | from .transformers import extractfigure |
|
31 | from .transformers import extractfigure | |
32 | from .utils.config import GlobalConfigurable |
|
32 | from .utils.config import GlobalConfigurable | |
@@ -127,10 +127,15 b' class NbConvertApp(Application):' | |||||
127 | ipynb_file = (self.extra_args)[2] |
|
127 | ipynb_file = (self.extra_args)[2] | |
128 |
|
128 | |||
129 | #Export |
|
129 | #Export | |
130 | return_value = export_by_name(export_type, ipynb_file) |
|
130 | try: | |
131 | if return_value is None: |
|
131 | return_value = export_by_name(export_type, ipynb_file) | |
132 | print("Error: '%s' template not found." % export_type) |
|
132 | except NameError as e: | |
133 | return |
|
133 | print("Error: '%s' exporter not found." % export_type, | |
|
134 | file=sys.stderr) | |||
|
135 | print("Known exporters are:", | |||
|
136 | "\n\t" + "\n\t".join(get_export_names()), | |||
|
137 | file=sys.stderr) | |||
|
138 | sys.exit(-1) | |||
134 | else: |
|
139 | else: | |
135 | (output, resources, exporter) = return_value |
|
140 | (output, resources, exporter) = return_value | |
136 |
|
141 |
General Comments 0
You need to be logged in to leave comments.
Login now