
    fi                     V    d Z ddlZddlmZ  ej                  d      Z G d de      Zy)zHPreprocessor for merging consecutive stream outputs for easier handling.    N)Preprocessorz.*\r(?=[^\n])c                       e Zd ZdZd Zy)CoalesceStreamsPreprocessorz
    Merge consecutive sequences of stream output into single stream
    to prevent extra newlines inserted at flush calls
    c                    |j                  dg       }|s||fS |d   }|g}|dd D ]l  }|j                  dk(  rH|j                  dk(  r9|j                  |j                  k(  r |xj                  |j                  z  c_        Z|j	                  |       |}n |D ]F  }|j                  dk(  sd|j                  v s"t
        j                  d|j                        |_        H ||_        ||fS )zO
        Apply a transformation on each cell. See base.py for details.
        outputsr      Nstream )getoutput_typenametextappendCR_PATsubr   )selfcell	resources
cell_indexr   lastnew_outputsoutputs           b/var/www/cvtools/html/venv/lib/python3.12/site-packages/nbconvert/preprocessors/coalescestreams.pypreprocess_cellz+CoalesceStreamsPreprocessor.preprocess_cell   s     ((9b)?"qzfabk 		F""h.$$0II,		V[[(	""6*		 " 	:F!!X-$&++2E$jjV[[9	: #Y    N)__name__
__module____qualname____doc__r    r   r   r   r      s    
r   r   )r    renbconvert.preprocessorsr   compiler   r   r!   r   r   <module>r%      s-    N 	 1	$	%!, !r   