diff --git a/converters/transformers.py b/converters/transformers.py index ea3e716..3c48788 100755 --- a/converters/transformers.py +++ b/converters/transformers.py @@ -29,12 +29,15 @@ class ConfigurableTransformers(Configurable): raise NotImplementedError('should be implemented by subclass') -class Foobar(ConfigurableTransformers): - message = Unicode('-- nothing', config=True) +class ActivatableTransformer(ConfigurableTransformers): + active = Bool(False, config=True) - def cell_transform(self, cell, other, index): - return cell, other + def __call__(self, nb, other): + if not self.active : + return nb,other + else : + return super(ActivatableTransformer,self).__call__(nb, other) def cell_preprocessor(function): @@ -73,7 +76,7 @@ def haspyout_transformer(cell, other, count): # todo, make the key part configurable. -class ExtractFigureTransformer(ConfigurableTransformers): +class ExtractFigureTransformer(ActivatableTransformer): enabled = Bool(False, config=True, help=""" If set to false, this transformer will be no-op """ diff --git a/runme.py b/runme.py index a913c44..3349f3a 100755 --- a/runme.py +++ b/runme.py @@ -30,7 +30,7 @@ from IPython.config.application import Application from IPython.config.loader import ConfigFileNotFound from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict, CaselessStrEnum -from converters.transformers import (ConfigurableTransformers,Foobar,ExtractFigureTransformer) +from converters.transformers import (ConfigurableTransformers,ExtractFigureTransformer) class NbconvertApp(Application): @@ -58,7 +58,6 @@ class NbconvertApp(Application): self.classes.insert(0,ConverterTemplate) # register class here to have help with help all self.classes.insert(0,ExtractFigureTransformer) - self.classes.insert(0,Foobar) # ensure those are registerd def load_config_file(self, profile_name):