From f76aadd1c385022d32cb383ee8a0bf436052c99a 2013-02-10 12:27:59 From: Matthias BUSSONNIER Date: 2013-02-10 12:27:59 Subject: [PATCH] share some global config state --- diff --git a/converters/config.py b/converters/config.py new file mode 100644 index 0000000..1d0c44f --- /dev/null +++ b/converters/config.py @@ -0,0 +1,20 @@ +from IPython.utils.traitlets import (Unicode, List, Bool) +from IPython.config.configurable import Configurable + +class GlobalConfigurable(Configurable): + """Global configurable class for shared config + + Usefull for display data priority that might be use by many trasnformers + """ + + display_data_priority = List(['html', 'pdf', 'svg', 'latex', 'png', 'jpg', 'jpeg' , 'text'], + config=True, + help= """ + An ordered list of prefered output type, the first + encounterd will usually be used when converting discarding + the others. + """ + ) + + def __init__(self, config=None, **kw): + super(GlobalConfigurable, self).__init__( config=config, **kw) diff --git a/converters/jinja_filters.py b/converters/jinja_filters.py index 2384721..5671578 100755 --- a/converters/jinja_filters.py +++ b/converters/jinja_filters.py @@ -17,6 +17,8 @@ from .utils import remove_ansi from .utils import highlight, ansi2html from .utils import markdown2latex +from converters.config import GlobalConfigurable + from IPython.config.configurable import Configurable from IPython.utils.traitlets import List @@ -24,24 +26,6 @@ from IPython.utils.traitlets import List # Class declarations #----------------------------------------------------------------------------- -class GlobalConfigurable(Configurable): - """Global configurable class for shared config - - Usefull for display data priority that might be use by many trasnformers - """ - - display_data_priority = List(['html', 'pdf', 'svg', 'latex', 'png', 'jpg', 'jpeg' , 'text'], - config=True, - help= """ - An ordered list of prefered output type, the first - encounterd will usually be used when converting discarding - the others. - """ - ) - - def __init__(self, config=None, **kw): - super(GlobalConfigurable, self).__init__( config=config, **kw) - class ConfigurableFilter(GlobalConfigurable): """Configurable Jinja Filter""" diff --git a/converters/template.py b/converters/template.py index 6920cc0..d8a85b5 100755 --- a/converters/template.py +++ b/converters/template.py @@ -42,7 +42,7 @@ from converters.jinja_filters import (python_comment, indent, ansi2html, markdown2latex, escape_tex, FilterDataType) from converters.utils import markdown2rst - +from converters.config import GlobalConfigurable diff --git a/converters/transformers.py b/converters/transformers.py index 2202582..7d65331 100755 --- a/converters/transformers.py +++ b/converters/transformers.py @@ -11,7 +11,9 @@ from __future__ import print_function from IPython.config.configurable import Configurable from IPython.utils.traitlets import Unicode, Bool, Dict, List -class ConfigurableTransformers(Configurable): +from converters.config import GlobalConfigurable + +class ConfigurableTransformers(GlobalConfigurable): """ A configurable transformer Inherit from this class if you wish to have configurability for your @@ -145,14 +147,6 @@ class ExtractFigureTransformer(ActivatableTransformer): Usefull for latex where svg will be converted to pdf before inclusion """ ) - display_data_priority = List(['html', 'pdf', 'svg', 'latex', 'png', 'jpg', 'jpeg' , 'text'], - config=True, - help= """ - An ordered list of prefered output type, the first - encounterd will usually be used when converting discarding - the others. - """ - ) key_format_map = Dict({}, config=True, diff --git a/nbconvert2.py b/nbconvert2.py index 5a15aa3..6bb0da5 100755 --- a/nbconvert2.py +++ b/nbconvert2.py @@ -30,7 +30,7 @@ from IPython.utils.traitlets import Unicode, Bool from converters.transformers import (ExtractFigureTransformer) -from converters.jinja_filters import GlobalConfigurable +from converters.config import GlobalConfigurable class NbconvertApp(Application):