
    f}                       U d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
Z
ddlmZ ddlmZmZmZmZmZ ddlmZ dd	lmZ d
dlmZ dddddZded<   dddiidfdddiidfdZded<    G d de      Zej:                  Zy)znbclient cli.    )annotationsN)Path)dedent)
JupyterApp)BoolIntegerListUnicodedefault)catch_config_error)__version__   )NotebookClientzNbClientApp.timeoutzNbClientApp.startup_timeoutzNbClientApp.kernel_namezNbClientApp.output_base)timeoutstartup_timeoutkernel_nameoutputzdict[str, str]nbclient_aliasesNbClientAppallow_errorsTzLErrors are ignored and execution is continued until the end of the notebook.inplacez/Overwrite input notebook with executed results.)zallow-errorsr   zdict[str, typing.Any]nbclient_flagsc                      e Zd ZdZ ee      ZdZeZ	e
ZdZ e e       d      j                  d      Z edd ed	      
      j                  d      Z ed ed            j                  d      Z ed ed            j                  d      Z ed ed            j                  d      Z ed ed            j                  d      Z ed ed            j                  d      Z edd ed      
      j                  d      Z ed      dd       Zedd fd       ZddZddZ xZ S )r   zE
    An application used to execute notebook files (``*.ipynb``)
    zjupyter-executez7An application used to execute notebook files (*.ipynb)zPath of notebooks to convert)helpT)configNz
            The time to wait (in seconds) for output from executions.
            If a cell execution takes longer, a TimeoutError is raised.
            ``-1`` will disable the timeout.
            )
allow_noner   <   z
            The time to wait (in seconds) for the kernel to start.
            If kernel startup takes longer, a RuntimeError is
            raised.
            FaB  
            When a cell raises an error the default behavior is that
            execution is stopped and a :py:class:`nbclient.exceptions.CellExecutionError`
            is raised.
            If this flag is provided, errors are ignored and execution
            is continued until the end of the notebook.
            zskip-executionz^
            Name of the cell tag to use to denote a cell that should be skipped.
             z
            Name of kernel to use to execute the cells.
            If not set, use the kernel_spec embedded in the notebook.
            z
            Default is execute notebook without writing the newly executed notebook.
            If this flag is provided, the newly generated notebook will
            overwrite the input notebook.
            a8  
            Write executed notebook to this file base name.
            Supports pattern replacements ``'{notebook_name}'``,
            the name of the input notebook file without extension.
            Note that output is always relative to the parent directory of the
            input notebook.
            	log_levelc                "    t         j                  S N)loggingINFO)selfs    G/var/www/cvtools/html/venv/lib/python3.12/site-packages/nbclient/cli.py_log_level_defaultzNbClientApp._log_level_default   s    ||    c                R   t         |   |       | j                         | _        | j                  st	        j
                  d       t        | j                        dkD  r'| j                  d| j                  vrd}t        |      | j                  D ]  }| j                  |        y)zInitialize the app.r   Nz{notebook_name}zgIf passing multiple notebooks with `--output=output` option, output string must contain {notebook_name})
super
initializeget_notebooks	notebookssysexitlenoutput_base
ValueErrorrun_notebook)r$   argvmsgpath	__class__s       r%   r+   zNbClientApp.initialize   s     	4  ++- ~~HHRL t~~"t'7'7'C (8(88A  !o% NN 	$Dd#	$r'   c                R    | j                   r| j                   }|S | j                  }|S )zGet the notebooks for the app.)
extra_argsr-   )r$   r-   s     r%   r,   zNbClientApp.get_notebooks   s/     ??I  I r'   c                   | j                   j                  d|        t        |      j                  d      }|j                  j                         }| j                  r|}nl| j                  r^|j                  j                  | j                  j                  |j                  d      j                              j                  d      }nd}|r5|j                  j                         sd|j                   d}t        |      |j                         5 }t        j                  |d	      }ddd       t!        | j"                  | j$                  | j&                  | j(                  | j*                  d
d|ii      }|j-                          |r5| j                   j                  d|        t        j.                  ||       yy# 1 sw Y   xY w)zRun a notebook by path.z
Executing z.ipynbr   )notebook_nameNzCannot write to directory=z that does not exist   )
as_versionmetadatar6   )r   r   skip_cells_with_tagr   r   	resourceszSave executed results to )loginfor   with_suffixparentabsoluter   r1   joinpathformatnameis_dirr2   opennbformatreadr   r   r   r?   r   r   executewrite)	r$   notebook_path
input_pathr6   output_pathr5   fnbclients	            r%   r3   zNbClientApp.run_notebook   s    	
=/23-(44X>
   ))+ <<$K$++44  ''j6L6LR6P6U6U'Vk(#  K{1188:.{/A/A.BBVWCS/! __ 	0!qQ/B	0  LL 00 $ 8 8**((!FD>2
 	 HHMM5k]CDNN2{+ %	0 	0s   GG)returnintr!   )r4   zlist[str] | NonerU   None)rU   z	list[str])rO   strrU   rW   )!__name__
__module____qualname____doc__r
   r   versionrH   r   aliasesr   flagsdescriptionr	   tagr-   r   r   r   r   r   r   r?   r   r   r1   r   r&   r   r+   r,   r3   __classcell__)r7   s   @r%   r   r   0   s    k"GDGEKKWY%CDHHPTHUI

 
cc  

	 
cc  
 
cc  "
 
cc  

 
cc  
	 
cc  
 
cc  [  $ $0
-,r'   )r\   
__future__r   r"   r.   typingpathlibr   textwrapr   rK   jupyter_core.applicationr   	traitletsr   r   r	   r
   r   traitlets.configr   nbclientr   rT   r   r   __annotations__r   r   launch_instancemain r'   r%   <module>ro      s     "  
     / ; ; /   "
 %4,'	$ .  	

 	W 4	

 	:)% (l,* l,^ ""r'   