o
    i                     @   s   d dl Z d dlZd dl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ZddddiidfiZG dd deZejZdS )    N)dedent)
JupyterApp)BoolIntegerListUnicodedefault)catch_config_error)__version__   )NotebookClientzNbClientApp.timeoutzNbClientApp.startup_timeoutzNbClientApp.kernel_name)timeoutstartup_timeoutkernel_namezallow-errorsNbClientAppallow_errorsTzLErrors are ignored and execution is continued until the end of the notebook.c                       s  e Zd ZU dZeeZdZeZ	e
ZdZeg ddjddZedded	d
jddZeed< ededdjddZeed< ededdjddZeed< ededdjddZeed< ededdjddZeed< eddd Zed! fdd	Zdd Z dd  Z!  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   r   <   z
            The time to wait (in seconds) for the kernel to start.
            If kernel startup takes longer, a RuntimeError is
            raised.
            r   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.
            r   zskip-executionz^
            Name of the cell tag to use to denote a cell that should be skipped.
            skip_cells_with_tag z
            Name of kernel to use to execute the cells.
            If not set, use the kernel_spec embedded in the notebook.
            r   	log_levelc                 C   s   t jS N)loggingINFOself r   G/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/nbclient/cli.py_log_level_default`   s   zNbClientApp._log_level_defaultc                    sN   t  |    _ jst j d td  fdd jD  d S )Nz": error: expected path to notebookc                    s   g | ]}  |qS r   )run_notebook).0pathr   r   r   
<listcomp>q   s    z*NbClientApp.initialize.<locals>.<listcomp>)super
initializeget_notebooks	notebooksprintnamesysexit)r   argv	__class__r   r   r'   d   s   

zNbClientApp.initializec                 C   s   | j r| j }|S | j}|S r   )
extra_argsr)   )r   r)   r   r   r   r(   s   s
   zNbClientApp.get_notebooksc              
   C   s   | j d|  |dd}t|j }| d}t|}tj	|dd}W d    n1 s2w   Y  t
|| j| j| j| j| jdd|iid}|  d S )	Nz
Executing z.ipynbr      )
as_versionmetadatar$   )r   r   r   r   r   	resources)loginforeplacepathlibPathparentabsoluteopennbformatreadr   r   r   r   r   r   execute)r   notebook_pathr+   r$   
input_pathfnbclientr   r   r   r"   ~   s"   


zNbClientApp.run_notebookr   )#__name__
__module____qualname____doc__r   r
   versionr+   nbclient_aliasesaliasesnbclient_flagsflagsdescriptionr   tagr)   r   r   r   int__annotations__r   r   r   boolr   strr   r   r    r	   r'   r(   r"   __classcell__r   r   r/   r   r   !   sn   
 
	


)r   r9   r,   textwrapr   r>   jupyter_core.applicationr   	traitletsr   r   r   r   r   traitlets.configr	   nbclientr
   rE   r   rK   rM   r   launch_instancemainr   r   r   r   <module>   s0    
|