##// END OF EJS Templates
Merge pull request #3627 from juliantaylor/static-path...
Merge pull request #3627 from juliantaylor/static-path use DEFAULT_STATIC_FILES_PATH in a test instead of package dir allows post installation tests with split static data to succeed

File last commit:

r11086:c137395d
r11345:ccdb3f55 merge
Show More
activatable.py
53 lines | 1.9 KiB | text/x-python | PythonLexer
Jonathan Frederic
Cleanup and refactor, transformers
r10674 """
Contains base transformer with an enable/disable flag.
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2013, the IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
Jonathan Frederic
Fixed all broken references, refactored some stuff here and there,...
r10624 from .base import ConfigurableTransformer
from IPython.utils.traitlets import (Bool)
Jonathan Frederic
Post code-review, extended refactor.
r10485
Jonathan Frederic
Cleanup and refactor, transformers
r10674 #-----------------------------------------------------------------------------
# Classes and Functions
#-----------------------------------------------------------------------------
Jonathan Frederic
Split transformer code
r10437
Jonathan Frederic
Cleanup and refactor, transformers
r10674 class ActivatableTransformer(ConfigurableTransformer):
"""ConfigurableTransformer that has an enabled flag
Jonathan Frederic
Split transformer code
r10437
Jonathan Frederic
Cleanup and refactor, transformers
r10674 Inherit from this if you just want to have a transformer which is
Matthias BUSSONNIER
start tinkerign with config system
r10862 disable by default and can be enabled via the config by
Jonathan Frederic
Cleanup and refactor, transformers
r10674 'c.YourTransformerName.enabled = True'
Jonathan Frederic
Split transformer code
r10437 """
Matthias BUSSONNIER
start tinkerign with config system
r10862 enabled = Bool(False, config=True)
Jonathan Frederic
Split transformer code
r10437
Jonathan Frederic
Cleanup and refactor, transformers
r10674 def __call__(self, nb, resources):
"""
Transformation to apply on each notebook.
You should return modified nb, resources.
If you wish to apply your transform on each cell, you might want to
overwrite cell_transform method instead.
Parameters
----------
nb : NotebookNode
Notebook being converted
resources : dictionary
Additional resources used in the conversion process. Allows
transformers to pass variables into the Jinja engine.
"""
Jonathan Frederic
Split transformer code
r10437 if not self.enabled :
Jonathan Frederic
Cleanup and refactor, transformers
r10674 return nb, resources
Jonathan Frederic
Split transformer code
r10437 else :
Jonathan Frederic
Cleanup and refactor, transformers
r10674 return super(ActivatableTransformer, self).__call__(nb, resources)