
]c           @   s@   d  Z  d d l m Z d d l m Z d e f d     YZ d S(   s   Base class for preprocessorsi   (   t   NbConvertBasei(   t   Boolt   Preprocessorc           B   sJ   e  Z d  Z e e  j d e  Z d   Z d   Z	 d   Z
 d   Z RS(   s7   A configurable preprocessor

    Inherit from this class if you wish to have configurability for your
    preprocessor.

    Any configurable traitlets this class exposed will be configurable in
    profiles using c.SubClassName.attribute = value

    you can overwrite :meth:`preprocess_cell` to apply a transformation
    independently on each cell or :meth:`preprocess` if you prefer your own
    logic. See corresponding docstring for information.

    Disabled by default and can be enabled via the config by
        'c.YourPreprocessorName.enabled = True'
    t   configc         K   s   t  t |   j |   d S(   s   
        Public constructor
        
        Parameters
        ----------
        config : Config
            Configuration file structure
        `**kw`
            Additional keyword arguments passed to parent
        N(   t   superR   t   __init__(   t   selft   kw(    (    s;   lib/python2.7/site-packages/nbconvert/preprocessors/base.pyR      s    c         C   s@   |  j  r2 |  j j d |  j j  |  j | |  S| | f Sd  S(   Ns   Applying preprocessor: %s(   t   enabledt   logt   debugt	   __class__t   __name__t
   preprocess(   R   t   nbt	   resources(    (    s;   lib/python2.7/site-packages/nbconvert/preprocessors/base.pyt   __call__+   s
    	c         C   sL   x? t  | j  D]. \ } } |  j | | |  \ | j | <} q W| | f S(   s  
        Preprocessing to apply on each notebook.
        
        Must return modified nb, resources.
        
        If you wish to apply your preprocessing to each cell, you might want
        to override preprocess_cell method instead.
        
        Parameters
        ----------
        nb : NotebookNode
            Notebook being converted
        resources : dictionary
            Additional resources used in the conversion process.  Allows
            preprocessors to pass variables into the Jinja engine.
        (   t	   enumeratet   cellst   preprocess_cell(   R   R   R   t   indext   cell(    (    s;   lib/python2.7/site-packages/nbconvert/preprocessors/base.pyR   3   s    &c         C   s   t  d   | | f S(   s  
        Override if you want to apply some preprocessing to each cell.
        Must return modified cell and resource dictionary.
        
        Parameters
        ----------
        cell : NotebookNode cell
            Notebook cell being processed
        resources : dictionary
            Additional resources used in the conversion process.  Allows
            preprocessors to pass variables into the Jinja engine.
        index : int
            Index of the cell being processed
        s!   should be implemented by subclass(   t   NotImplementedError(   R   R   R   R   (    (    s;   lib/python2.7/site-packages/nbconvert/preprocessors/base.pyR   H   s    (   R   t
   __module__t   __doc__R   t   Falset   tagt   TrueR   R   R   R   R   (    (    (    s;   lib/python2.7/site-packages/nbconvert/preprocessors/base.pyR   
   s   			N(   R   t
   utils.baseR    t	   traitletsR   R   (    (    (    s;   lib/python2.7/site-packages/nbconvert/preprocessors/base.pyt   <module>   s   