o
    i                     @   s6  d Z ddlZddlZede ddlmZ ddlmZ	 ddl
mZmZmZmZmZmZmZmZmZ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lm Z m!Z! g dZ"eZ#eZ$e	j%Z&G dd de'Z(dd Z)dd Z*dd Z+dd Z,dd Z-dd Z.de#fddZde#fddZ/d$d d!Z0d$d"d#Z1dS )%zDeprecated API for working with notebooks

- use nbformat for read/write/validate public API
- use nbformat.vX directly for Python API for composing notebooks
    Nznbformat.current is deprecated since before nbformat 3.0

- use nbformat for read/write/validate public API
- use nbformat.vX directly to composing notebooks of a particular version
)
get_logger)v3)NotebookNodenbformatnbformat_minornbformat_schema
new_authornew_code_cellnew_heading_cellnew_metadatanew_notebook
new_outputnew_text_cellnew_worksheetparse_filenameto_notebook_json   )versions)convert)reads)ValidationErrorvalidate)r   r	   r   r   r   r   r   r   r   r
   r   r   r   r   r   r   NBFormatErrorparse_py
reads_jsonwrites_jsonreads_py	writes_pyr   writesreadwritec                   @   s   e Zd ZdZdS )r   z&An error raised for an nbformat error.N)__name__
__module____qualname____doc__ r%   r%   K/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/nbformat/current.pyr   R   s    r   c                   C   s   t d d S )NzwNon-JSON file support in nbformat is deprecated since nbformat 1.0.
    Use nbconvert to create files of other formats.)warningswarnr%   r%   r%   r&   _warn_formatX   s   r)   c                 K   s^   t }t}d}t|| }|dur*|dd}t|d }t|dkr*t|d }||| fS )z/Parse a string into a (nbformat, string) tuple.z0# <nbformat>(?P<nbformat>\d+[\.\d+]*)</nbformat>Nr   .r   r   )current_nbformatcurrent_nbformat_minorresearchgroupsplitintlen)skwargsnbfnbmpatternmdigitsr%   r%   r&   r   _   s   
r   c                 K   s   t jdtdd t| S )zDEPRECATED, use readsz6reads_json is deprecated since nbformat 3.0, use reads   
stacklevel)r'   r(   DeprecationWarningr   )nbjsonr4   r%   r%   r&   r   o   s   r   c                 K   s    t jdtdd t| fi |S )zDEPRECATED, use writesz8writes_json is deprecated since nbformat 3.0, use writesr:   r;   )r'   r(   r=   r   nbr4   r%   r%   r&   r   y   s   r   c                 K   sJ   t   t| fi |\}}} |dv rt| j| fi |}|S td| )DEPRECATED: use nbconvert)r:      z#Unsupported PY nbformat version: %i)r)   r   r   to_notebook_pyr   )r3   r4   r5   r6   r@   r%   r%   r&   r      s   r   c                 K   s   t   td j| fi |S )rA   rB   )r)   r   r   r?   r%   r%   r&   r      s   r   
DEPRECATEDc              
   K   s   |dvrt   t| fi |}t||}z&t  tjdtd t|dd W d   W |S 1 s3w   Y  W |S  tyT } zt	 
d| W Y d}~|S d}~ww )a  Read a notebook from a string and return the NotebookNode object.

    This function properly handles notebooks of any version. The notebook
    returned will always be in the current version's format.

    Parameters
    ----------
    s : unicode
        The raw unicode string to read the notebook from.

    Returns
    -------
    nb : NotebookNode
        The notebook that was read.
    >   jsonrD   ignorecategoryFrepair_duplicate_cell_idsNNotebook JSON is invalid: %s)r)   reader_readsr   r'   catch_warningsfilterwarningsr=   r   r   r   error)r3   formatversionr4   r@   er%   r%   r&   r      s"   

r   c              
   K   s   |dvrt   t| |} z#t  tjdtd t| dd W d   n1 s)w   Y  W n tyH } zt 	d| W Y d}~nd}~ww t
| j| fi |S )a  Write a notebook to a string in a given format in the current nbformat version.

    This function always writes the notebook in the current nbformat version.

    Parameters
    ----------
    nb : NotebookNode
        The notebook to write.
    version : int
        The nbformat version to write.
        Used for downgrading notebooks.

    Returns
    -------
    s : unicode
        The notebook string.
    >   rE   rD   rF   rG   FrI   NrK   )r)   r   r'   rM   rN   r=   r   r   r   rO   r   r   )r@   rP   rQ   r4   rR   r%   r%   r&   r      s   

r   c                 K   s   t |  fi |S )a}  Read a notebook from a file and return the NotebookNode object.

    This function properly handles notebooks of any version. The notebook
    returned will always be in the current version's format.

    Parameters
    ----------
    fp : file
        Any file-like object with a read method.

    Returns
    -------
    nb : NotebookNode
        The notebook that was read.
    )r   r   )fprP   r4   r%   r%   r&   r      s   r   c                 K   s.   t | fi |}t|tr|d}||S )a5  Write a notebook to a file in a given format in the current nbformat version.

    This function always writes the notebook in the current nbformat version.

    Parameters
    ----------
    nb : NotebookNode
        The notebook to write.
    fp : file
        Any file-like object with a write method.
    utf8)r   
isinstancebytesdecoder    )r@   rS   rP   r4   r3   r%   r%   r&   r       s   


r    )rD   )2r$   r-   r'   r(   r=   traitlets.logr   r   r   	_v_latestnbformat.v3r   r   r   r   r	   r
   r   r   r   r   r   r   r    r   	converterr   readerr   rL   	validatorr   r   __all__r+   r,   r!   current_nbformat_module
ValueErrorr   r)   r   r   r   r   r   r   r   r    r%   r%   r%   r&   <module>   s:    
	@

	
