From cc5157d69575185540ccce64427f43a4b404c6dc Mon Sep 17 00:00:00 2001 From: Tyler Makaro Date: Wed, 24 Apr 2019 21:22:14 -0700 Subject: [PATCH] fix duplicates in download as meny --- notebook/notebook/handlers.py | 18 ++++++++++++------ notebook/templates/notebook.html | 10 +--------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/notebook/notebook/handlers.py b/notebook/notebook/handlers.py index 82110a81a..9d47f47c2 100644 --- a/notebook/notebook/handlers.py +++ b/notebook/notebook/handlers.py @@ -15,16 +15,22 @@ from ..utils import url_escape from ..transutils import _ -def get_custom_frontend_exporters(): +def get_frontend_exporters(): from nbconvert.exporters.base import get_export_names, get_exporter ExporterInfo = namedtuple('ExporterInfo', ['name', 'display']) for name in sorted(get_export_names()): - exporter = get_exporter(name)() - ux_name = getattr(exporter, 'export_from_notebook', None) - if ux_name is not None: - display = _('{} ({})'.format(ux_name, exporter.file_extension)) + exporter_class = get_exporter(name) + exporter_instance = exporter_class() + ux_name = getattr(exporter_instance, 'export_from_notebook', None) + # ensure export_from_notebook is explicitly defined & not inherited + super_uxname = getattr(super(exporter_class, exporter_instance), + 'export_from_notebook', + None) + if ux_name is not None and ux_name != super_uxname: + display = _('{} ({})'.format(ux_name, + exporter_instance.file_extension)) yield ExporterInfo(name, display) @@ -56,7 +62,7 @@ class NotebookHandler(IPythonHandler): kill_kernel=False, mathjax_url=self.mathjax_url, mathjax_config=self.mathjax_config, - get_custom_frontend_exporters=get_custom_frontend_exporters + get_frontend_exporters=get_frontend_exporters ) ) diff --git a/notebook/templates/notebook.html b/notebook/templates/notebook.html index 828851f3b..579cc45c5 100644 --- a/notebook/templates/notebook.html +++ b/notebook/templates/notebook.html @@ -111,15 +111,7 @@ data-notebook-path="{{notebook_path | urlencode}}"