diff --git a/nbconvert/exporters/qt_exporter.py b/nbconvert/exporters/qt_exporter.py index 658327c6e..cd4fefaa1 100644 --- a/nbconvert/exporters/qt_exporter.py +++ b/nbconvert/exporters/qt_exporter.py @@ -2,7 +2,6 @@ import sys import tempfile -from jupyter_core.paths import jupyter_path from traitlets import default from .html import HTMLExporter @@ -12,27 +11,14 @@ class QtExporter(HTMLExporter): paginate = None - def __init__(self, *args, **kwargs): - self.format = self.output_mimetype.split("/")[-1] - super().__init__(*args, **kwargs) - @default("file_extension") def _file_extension_default(self): - return "." + self.format - - @default("template_name") - def _template_name_default(self): - return "qt" + self.format - - @default("template_data_paths") - def _template_data_paths_default(self): - return jupyter_path("nbconvert", "templates", "qt" + self.format) + return ".html" def _check_launch_reqs(self): if sys.platform.startswith("win") and self.format == "png": raise RuntimeError("Exporting to PNG using Qt is currently not supported on Windows.") from .qt_screenshot import QT_INSTALLED - if not QT_INSTALLED: raise RuntimeError( f"PyQtWebEngine is not installed to support Qt {self.format.upper()} conversion. " @@ -42,15 +28,12 @@ def _check_launch_reqs(self): return QtScreenshot - def run_pyqtwebengine(self, html): - """Run pyqtwebengine.""" - + def _run_pyqtwebengine(self, html): ext = ".html" temp_file = tempfile.NamedTemporaryFile(suffix=ext, delete=False) filename = f"{temp_file.name[:-len(ext)]}.{self.format}" with temp_file: temp_file.write(html.encode("utf-8")) - try: QtScreenshot = self._check_launch_reqs() s = QtScreenshot() @@ -65,7 +48,7 @@ def from_notebook_node(self, nb, resources=None, **kw): html, resources = super().from_notebook_node(nb, resources=resources, **kw) self.log.info(f"Building {self.format.upper()}") - data = self.run_pyqtwebengine(html) + data = self._run_pyqtwebengine(html) self.log.info(f"{self.format.upper()} successfully created") # convert output extension diff --git a/nbconvert/exporters/qtpdf.py b/nbconvert/exporters/qtpdf.py index 0c2b8bfe9..738a9f701 100644 --- a/nbconvert/exporters/qtpdf.py +++ b/nbconvert/exporters/qtpdf.py @@ -16,6 +16,7 @@ class QtPDFExporter(QtExporter): """ export_from_notebook = "PDF via HTML" + format = "pdf" paginate = Bool( True, @@ -27,5 +28,3 @@ class QtPDFExporter(QtExporter): Set to True to match behavior of LaTeX based PDF generator """, ).tag(config=True) - - output_mimetype = "application/pdf" diff --git a/nbconvert/exporters/qtpng.py b/nbconvert/exporters/qtpng.py index 20b90b6da..d506a432b 100644 --- a/nbconvert/exporters/qtpng.py +++ b/nbconvert/exporters/qtpng.py @@ -14,5 +14,4 @@ class QtPNGExporter(QtExporter): """ export_from_notebook = "PNG via HTML" - - output_mimetype = "image/png" + format = "png" diff --git a/nbconvert/exporters/webpdf.py b/nbconvert/exporters/webpdf.py index dfc99077c..a95648575 100644 --- a/nbconvert/exporters/webpdf.py +++ b/nbconvert/exporters/webpdf.py @@ -38,8 +38,6 @@ class WebPDFExporter(HTMLExporter): """, ).tag(config=True) - output_mimetype = "text/html" - @default("file_extension") def _file_extension_default(self): return ".html" diff --git a/share/templates/qtpdf/conf.json b/share/templates/qtpdf/conf.json deleted file mode 100644 index 66e95837a..000000000 --- a/share/templates/qtpdf/conf.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "base_template": "lab", - "mimetypes": { - "application/pdf": true - } -} diff --git a/share/templates/qtpdf/index.pdf.j2 b/share/templates/qtpdf/index.pdf.j2 deleted file mode 100644 index 047c0dcce..000000000 --- a/share/templates/qtpdf/index.pdf.j2 +++ /dev/null @@ -1 +0,0 @@ -{%- extends 'lab/index.html.j2' -%} diff --git a/share/templates/qtpng/conf.json b/share/templates/qtpng/conf.json deleted file mode 100644 index b3ae45a9e..000000000 --- a/share/templates/qtpng/conf.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "base_template": "lab", - "mimetypes": { - "image/png": true - } -} diff --git a/share/templates/qtpng/index.png.j2 b/share/templates/qtpng/index.png.j2 deleted file mode 100644 index 047c0dcce..000000000 --- a/share/templates/qtpng/index.png.j2 +++ /dev/null @@ -1 +0,0 @@ -{%- extends 'lab/index.html.j2' -%}