mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-30 12:11:32 +08:00
Merge pull request #3879 from starcruiseromega/exporters
Get the list of exporters from entrypoints
This commit is contained in:
commit
6c0ee1ba12
@ -4,18 +4,32 @@ from tornado import web
|
|||||||
|
|
||||||
from ...base.handlers import APIHandler
|
from ...base.handlers import APIHandler
|
||||||
|
|
||||||
|
|
||||||
class NbconvertRootHandler(APIHandler):
|
class NbconvertRootHandler(APIHandler):
|
||||||
|
|
||||||
@web.authenticated
|
@web.authenticated
|
||||||
def get(self):
|
def get(self):
|
||||||
try:
|
try:
|
||||||
from nbconvert.exporters.export import exporter_map
|
from nbconvert.exporters import base
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise web.HTTPError(500, "Could not import nbconvert: %s" % e)
|
raise web.HTTPError(500, "Could not import nbconvert: %s" % e)
|
||||||
res = {}
|
res = {}
|
||||||
for format, exporter in exporter_map.items():
|
exporters = base.get_export_names()
|
||||||
res[format] = info = {}
|
for exporter_name in exporters:
|
||||||
info['output_mimetype'] = exporter.output_mimetype
|
try:
|
||||||
|
exporter_class = base.get_exporter(exporter_name)
|
||||||
|
except ValueError:
|
||||||
|
# I think the only way this will happen is if the entrypoint
|
||||||
|
# is uninstalled while this method is running
|
||||||
|
continue
|
||||||
|
# XXX: According to the docs, it looks like this should be set to None
|
||||||
|
# if the exporter shouldn't be exposed to the front-end and a friendly
|
||||||
|
# name if it should. However, none of the built-in exports have it defined.
|
||||||
|
# if not exporter_class.export_from_notebook:
|
||||||
|
# continue
|
||||||
|
res[exporter_name] = {
|
||||||
|
"output_mimetype": exporter_class.output_mimetype,
|
||||||
|
}
|
||||||
|
|
||||||
self.finish(json.dumps(res))
|
self.finish(json.dumps(res))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user