
    Mh                        U d Z ddlmZ ddlmZ ddlmZ  G d de          Z G d de	e          Z
 G d	 d
e          Z G d de          Z G d de          ZdZded<   dZded<   dZded<   dS )zExceptions for nbclient.    )annotations)Any)NotebookNodec                      e Zd ZdZdS )CellControlSignalz
    A custom exception used to indicate that the exception is used for cell
    control actions (not the best model, but it's needed to cover existing
    behavior without major refactors).
    N__name__
__module____qualname____doc__     S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/nbclient/exceptions.pyr   r   	   s          	Dr   r   c                  *    e Zd ZdZedd	            Zd
S )CellTimeoutErrorzS
    A custom exception to capture when a cell has timed out during execution.
    msgstrtimeoutintcellr   returnc                    |re|j         r^|j                                                             d          }t          |          dk     r|j         n|dd          d|dd          }nd} | t                              |||                    S )	z)Create an error from a timeout on a cell.
   N   z
...
zCell contents not found.)r   r   cell_contents)sourcestripsplitlentimeout_err_msgformat)clsr   r   r   src_by_linessrcs         r   error_from_timeout_and_cellz,CellTimeoutError.error_from_timeout_and_cell   s    
  	-DK 	-;,,..44T::L |$$r)) $RaR(DDbcc1BDD C -Cs?))'sRU)VVWWWr   N)r   r   r   r   r   r   r   r   )r	   r
   r   r   classmethodr'   r   r   r   r   r      sD          X X X [X X Xr   r   c                      e Zd ZdZdS )DeadKernelErrorzA dead kernel error.Nr   r   r   r   r*   r*   )   s        Dr   r*   c                      e Zd ZdZdS )CellExecutionCompletez
    Used as a control signal for cell execution across execute_cell and
    process_message function calls. Raised when all execution requests
    are completed and no further messages are expected from the kernel
    over zeromq channels.
    Nr   r   r   r   r,   r,   /   s          	Dr   r,   c                  L     e Zd ZdZd fdZdd
ZddZedd            Z xZ	S )CellExecutionErrorz
    Custom exception to propagate exceptions that are raised during
    notebook execution to the caller. This is mostly useful when
    using nbconvert as a library, since it allows to deal with
    failures gracefully.
    	tracebackr   enameevaluer   Nonec                t    t                                          |           || _        || _        || _        dS )zInitialize the error.N)super__init__r/   r0   r1   )selfr/   r0   r1   	__class__s       r   r5   zCellExecutionError.__init__B   s4    ###"
r   
tuple[Any]c                H    t          |           | j        | j        | j        ffS )zReduce implementation.)typer/   r0   r1   r6   s    r   
__reduce__zCellExecutionError.__reduce__I   s     DzzDNDJDDDr   c                @    | j         r| j         S | j         d| j         S )z	Str repr.z: )r/   r0   r1   r;   s    r   __str__zCellExecutionError.__str__M   s,    > 	2>!j11DK111r   r   r   r   dict[str, Any]c                H   g }|j         D ][}|d         dk    rM|                    t                              |d         |d                                                              \|r+|                    dd           |                    d           d	                    |          }d	                    |                    d
g           pg           } | t                              |||          |                    dd          |                    dd                    S )zvInstantiate from a code cell object and a message contents
        (message is either execute_reply or error)
        output_typestreamnametext)rC   rD   r    z------------------r   r/   )r   stream_outputr/   r0   z<Error>r1   )r0   r1   )	outputsappendstream_output_msgr#   rstripinsertjoingetexec_err_msg)r$   r   r   stream_outputsoutputrF   tbs          r   from_cell_and_msgz$CellExecutionError.from_cell_and_msgT   s7    %'l 	 	Fm$00%%%,,&.vf~G\G\G^G^,__    	8 !!!R(((!!"6777!YY~66YYsww{B//5266s+    
 '''9--778R((
 
 
 	
r   )r/   r   r0   r   r1   r   r   r2   )r   r8   )r   r   )r   r   r   r?   r   r.   )
r	   r
   r   r   r5   r<   r>   r(   rR   __classcell__)r7   s   @r   r.   r.   :   s              E E E E2 2 2 2 
 
 
 [
 
 
 
 
r   r.   z----- {name} -----
{text}r   rI   zAn error occurred while executing the following cell:
------------------
{cell.source}
------------------
{stream_output}

{traceback}
rN   zA cell timed out while it was being executed, after {timeout} seconds.
The message was: {msg}.
Here is a preview of the cell contents:
-------------------
{cell_contents}
-------------------
r"   N)r   
__future__r   typingr   nbformatr   	Exceptionr   TimeoutErrorr   RuntimeErrorr*   r,   r.   rI   __annotations__rN   r"   r   r   r   <module>r[      s      " " " " " "       ! ! ! ! ! !	 	 	 	 		 	 	 	X X X X X|%6 X X X,	 	 	 	 	l 	 	 		 	 	 	 	- 	 	 	7
 7
 7
 7
 7
* 7
 7
 7
t
  
 
 
 
          r   