
    Mh                    ^   d Z ddlmZ ddlZddlZ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!  ej"        de#d           g dZ$eZ%eZ&e	j'        Z( G d de)          Z*d Z+d Z,d Z-d Z.d Z/d Z0de%fdZde%fdZ1ddZ2ddZ3d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
    )annotationsN)
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validateznbformat.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
   
stacklevel)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                      e Zd ZdZdS )r   z&An error raised for an nbformat error.N)__name__
__module____qualname____doc__     P/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/nbformat/current.pyr   r   S   s        0000r,   r   c                 2    t          j        dd           d S )NzwNon-JSON file support in nbformat is deprecated since nbformat 1.0.
    Use nbconvert to create files of other formats.r   r   )warningswarnr+   r,   r-   _warn_formatr1   W   s-    M	7     r,   c                $   t           }t          }d}t          j        ||           }|e|                    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digitss          r-   r   r   _   s    
C
 CAG
	'1A}$$**3//&)nnv;;??fQi..CQ;r,   c                X    t          j        dt          d           t          |           S )zDEPRECATED, use readsz6reads_json is deprecated since nbformat 3.0, use readsr   r   )r/   r0   DeprecationWarningr   )nbjsonr=   s     r-   r   r   o   s2    M@   
 ==r,   c                T    t          j        dt          d           t          | fi |S )zDEPRECATED, use writesz8writes_json is deprecated since nbformat 3.0, use writesr   r   )r/   r0   rD   r#   nbr=   s     r-   r    r    y   s<    MB   
 "r,   c                    t                       t          | fi |\  }}} |dv rt          |         j        | fi |}nt	          d|z            |S )DEPRECATED: use nbconvert)r      z#Unsupported PY nbformat version: %i)r1   r   r   to_notebook_pyr   )r<   r=   r>   r?   rH   s        r-   r!   r!      sf    NNN1''''KCa
f}}c])!66v66ACGHHHIr,   c                N    t                       t          d         j        | fi |S )rJ   rK   )r1   r   r"   rG   s     r-   r"   r"      s(    NNNA; ..v...r,   
DEPRECATEDc                   |dvrt                       t          | fi |}t          ||          }	 t          j                    5  t          j        dt                     t          |d           ddd           n# 1 swxY w Y   n9# t          $ r,}t                      
                    d|           Y d}~nd}~ww xY w|S )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.
    >   jsonrN   ignorecategoryFrepair_duplicate_cell_idsNNotebook JSON is invalid: %s)r1   reader_readsr   r/   catch_warningsfilterwarningsrD   r   r   r   error)r<   formatversionr=   rH   es         r-   r   r      s!     +++	a	"	"6	"	"B	W		B>$&& 	: 	:#H7IJJJJR59999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:  > > >91========>Is;   B	 -A=1B	 =BB	 BB	 	
B?"B::B?c                   |dvrt                       t          | |          } 	 t          j                    5  t          j        dt
                     t          | d           ddd           n# 1 swxY w Y   n9# t          $ r,}t                      	                    d|           Y d}~nd}~ww xY 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.
    >   rP   rN   rQ   rR   FrT   NrV   )r1   r   r/   rX   rY   rD   r   r   r   rZ   r   r    )rH   r[   r\   r=   r]   s        r-   r#   r#      s%   $ +++	W		B>$&& 	: 	:#H7IJJJJR59999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:  > > >91========>G(66v666s:   A< -A0$A< 0A44A< 7A48A< <
B2"B--B2c                @    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$   )fpr[   r=   s      r-   r$   r$      s"      %%f%%%r,   c                    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%   )rH   r`   r[   r=   r<   s        r-   r%   r%      sL     	rVA!U HHV88A;;r,   )rN   )4r*   
__future__r   r6   r/   traitlets.logr   r   r   	_v_latestnbformat.v3r   r   r	   r
   r   r   r   r   r   r   r   r   r    r   	converterr   readerr   rW   	validatorr   r   r0   rD   __all__r4   r5   r'   current_nbformat_module
ValueErrorr   r1   r   r   r    r!   r"   r#   r$   r%   r+   r,   r-   <module>rq      s    # " " " " " 				  $ $ $ $ $ $ $ $ $ $ $ $                               "             ) ) ) ) ) ) 0 0 0 0 0 0 0 0 
      :  ' #, 1 1 1 1 1J 1 1 1              / / / !*:    : #,< 7 7 7 7<& & & &&     r,   