From 39de146775bab2f3c3020283f076c420b1e8d15a 2013-12-13 22:46:51 From: Thomas Kluyver Date: 2013-12-13 22:46:51 Subject: [PATCH] Make output_mimetype accessible from the class. Traitlets are only accessible by instantiating the class. There's no clear reason that this needs to be a traitlet, anyway. --- diff --git a/IPython/nbconvert/exporters/exporter.py b/IPython/nbconvert/exporters/exporter.py index 26e1fe4..cc77fc7 100644 --- a/IPython/nbconvert/exporters/exporter.py +++ b/IPython/nbconvert/exporters/exporter.py @@ -53,9 +53,10 @@ class Exporter(LoggingConfigurable): help="Extension of the file that should be written to disk" ) - output_mimetype = Unicode('', config=True, - help="MIME type of the result file, for HTTP response headers." - ) + # MIME type of the result file, for HTTP response headers. + # This is *not* a traitlet, because we want to be able to access it from + # the class, not just on instances. + output_mimetype = '' #Configurability, allows the user to easily add filters and preprocessors. preprocessors = List(config=True, diff --git a/IPython/nbconvert/exporters/html.py b/IPython/nbconvert/exporters/html.py index 95790c1..8cb8675 100644 --- a/IPython/nbconvert/exporters/html.py +++ b/IPython/nbconvert/exporters/html.py @@ -43,8 +43,7 @@ class HTMLExporter(TemplateExporter): default_template = Unicode('full', config=True, help="""Flavor of the data format to use. I.E. 'full' or 'basic'""") - def _output_mimetype_default(self): - return 'text/html' + output_mimetype = 'text/html' @property def default_config(self): diff --git a/IPython/nbconvert/exporters/latex.py b/IPython/nbconvert/exporters/latex.py index 551e535..0a94b9d 100644 --- a/IPython/nbconvert/exporters/latex.py +++ b/IPython/nbconvert/exporters/latex.py @@ -63,8 +63,7 @@ class LatexExporter(TemplateExporter): #Extension that the template files use. template_extension = Unicode(".tplx", config=True) - def _output_mimetype_default(self): - return 'text/latex' + output_mimetype = 'text/latex' @property diff --git a/IPython/nbconvert/exporters/markdown.py b/IPython/nbconvert/exporters/markdown.py index 4013c3f..6a888ae 100644 --- a/IPython/nbconvert/exporters/markdown.py +++ b/IPython/nbconvert/exporters/markdown.py @@ -30,8 +30,7 @@ class MarkdownExporter(TemplateExporter): 'md', config=True, help="Extension of the file that should be written to disk") - def _output_mimetype_default(self): - return 'text/markdown' + output_mimetype = 'text/markdown' def _raw_mimetypes_default(self): return ['text/markdown', 'text/html', ''] diff --git a/IPython/nbconvert/exporters/python.py b/IPython/nbconvert/exporters/python.py index 750b0ac..b5a4293 100644 --- a/IPython/nbconvert/exporters/python.py +++ b/IPython/nbconvert/exporters/python.py @@ -29,5 +29,4 @@ class PythonExporter(TemplateExporter): 'py', config=True, help="Extension of the file that should be written to disk") - def _output_mimetype_default(self): - return 'text/x-python' + output_mimetype = 'text/x-python' diff --git a/IPython/nbconvert/exporters/rst.py b/IPython/nbconvert/exporters/rst.py index 0bf4ead..e401c99 100644 --- a/IPython/nbconvert/exporters/rst.py +++ b/IPython/nbconvert/exporters/rst.py @@ -30,8 +30,7 @@ class RSTExporter(TemplateExporter): 'rst', config=True, help="Extension of the file that should be written to disk") - def _output_mimetype_default(self): - return 'text/restructuredtext' + output_mimetype = 'text/restructuredtext' @property def default_config(self): diff --git a/IPython/nbconvert/exporters/slides.py b/IPython/nbconvert/exporters/slides.py index 6b59e00..1a4ebec 100644 --- a/IPython/nbconvert/exporters/slides.py +++ b/IPython/nbconvert/exporters/slides.py @@ -31,8 +31,7 @@ class SlidesExporter(HTMLExporter): help="Extension of the file that should be written to disk" ) - def _output_mimetype_default(self): - return 'text/html' + output_mimetype = 'text/html' default_template = Unicode('reveal', config=True, help="""Template of the data format to use. I.E. 'reveal'""") diff --git a/IPython/nbconvert/exporters/templateexporter.py b/IPython/nbconvert/exporters/templateexporter.py index cdc1ee6..e127ab9 100644 --- a/IPython/nbconvert/exporters/templateexporter.py +++ b/IPython/nbconvert/exporters/templateexporter.py @@ -126,8 +126,6 @@ class TemplateExporter(Exporter): help="""Dictionary of filters, by name and namespace, to add to the Jinja environment.""") - output_mimetype = Unicode('') - raw_mimetypes = List(config=True, help="""formats of raw cells to be included in this Exporter's output.""" )