a
    ø£Beû
  ã                   @   s0   d Z ddlmZ ddlmZ G dd„ deƒZdS )zBase class for preprocessorsé    )ÚBool)ÚNbConvertBasec                       sH   e Zd ZdZedƒjdd�Z‡ fdd„Zdd„ Zd	d
„ Z	dd„ Z
‡  ZS )ÚPreprocessora.  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 `preprocess_cell()` to apply a transformation
    independently on each cell or `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'
    FT)Úconfigc                    s   t ƒ jf i |¤Ž dS )zÕ
        Public constructor

        Parameters
        ----------
        config : Config
            Configuration file structure
        `**kw`
            Additional keyword arguments passed to parent
        N)ÚsuperÚ__init__)ÚselfÚkw©Ú	__class__© ú_/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/nbconvert/preprocessors/base.pyr      s    zPreprocessor.__init__c                 C   s0   | j r$| j d| jj¡ |  ||¡S ||fS dS )zApply the preprocessor.zApplying preprocessor: %sN)ÚenabledÚlogÚdebugr   Ú__name__Ú
preprocess)r   ÚnbÚ	resourcesr   r   r   Ú__call__,   s    zPreprocessor.__call__c                 C   s4   t |jƒD ] \}}|  |||¡\|j|< }q
||fS )aú  
        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.
        )Ú	enumerateÚcellsÚpreprocess_cell)r   r   r   ÚindexÚcellr   r   r   r   4   s    zPreprocessor.preprocessc                 C   s   d}t |ƒ‚dS )aê  
        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
        z!should be implemented by subclassN)ÚNotImplementedError)r   r   r   r   Úmsgr   r   r   r   I   s    zPreprocessor.preprocess_cell)r   Ú
__module__Ú__qualname__Ú__doc__r   Útagr   r   r   r   r   Ú__classcell__r   r   r
   r   r      s   r   N)r   Z	traitletsr   Znbconvert.utils.baser   r   r   r   r   r   Ú<module>   s   