
    Mh
                     >    d Z ddlmZ ddlmZ  G d de          ZdS )zBase class for preprocessors    )Bool)NbConvertBasec                   r     e Zd ZdZ ed                              d          Z fdZd Zd Z	d Z
 x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                 :     t                      j        d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__s     \/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/nbconvert/preprocessors/base.pyr   zPreprocessor.__init__   s(     	2    c                     | j         r;| j                            d| j        j                   |                     ||          S ||fS )zApply the preprocessor.zApplying preprocessor: %s)enabledlogdebugr   __name__
preprocess)r   nb	resourcess      r   __call__zPreprocessor.__call__,   sF    < 	2HNN68OPPP??2y1119}r   c                     t          |j                  D ]'\  }}|                     |||          \  |j        |<   }(||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cells        r   r   zPreprocessor.preprocess3   sQ    " %RX.. 	V 	VKE4)-)=)=dIu)U)U&BHUOYY9}r   c                 $    d}t          |          )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 subclass)NotImplementedError)r   r   r   r   msgs        r   r   zPreprocessor.preprocess_cellH   s     2!#&&&r   )r   
__module____qualname____doc__r   tagr   r   r   r   r   __classcell__)r   s   @r   r   r      s           d5kkooTo**G        *' ' ' ' ' ' 'r   r   N)r%   	traitletsr   nbconvert.utils.baser   r   r	   r   r   <module>r*      so    " "
       . . . . . .M' M' M' M' M'= M' M' M' M' M'r   