B
    '=[                 @   sp  d Z ddlmZ ddlZddlZed 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 ddlmZm Z  ddl!m"Z" dddddddddddddddddddd d!d"d#d$d%d&g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d0d#Zd/e$fd1d$Z0d4d2d%Z1d5d3d&Z2dS )6zDeprecated API for working with notebooks

- use nbformat for read/write/validate public API
- use nbformat.vX directly for Python API for composing notebooks
    )print_functionNznbformat.current is deprecated.

- use nbformat for read/write/validate public API
- use nbformat.vX directly to composing notebooks of a particular version
)NotebookNodenew_code_cellnew_text_cellnew_notebook
new_outputnew_worksheetparse_filenamenew_metadata
new_authornew_heading_cellnbformatnbformat_minornbformat_schemato_notebook_json)v3   )reads)versions)convert)validateValidationError)
get_loggerr   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S )r   N)__name__
__module____qualname__ r%   r%   /lib/python3.7/site-packages/nbformat/current.pyr   0   s   c               C   s   t d d S )NzdNon-JSON file support in nbformat is deprecated.
    Use nbconvert to create files of other formats.)warningswarnr%   r%   r%   r&   _warn_format4   s    r)   c             K   s^   t }t}d}t|| }|dk	rT|dd}t|d }t|dkrTt|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mZdigitsr%   r%   r&   r   9   s    c             K   s   t d t| S )zDEPRECATED, use readsz#reads_json is deprecated, use reads)r'   r(   r   )Znbjsonr4   r%   r%   r&   r   I   s    
c             K   s   t d t| f|S )zDEPRECATED, use writesz%writes_json is deprecated, use writes)r'   r(   r   )nbr4   r%   r%   r&   r   N   s    
c             K   sD   t   t| f|\}}} |dkr4t| j| f|}ntd| |S )zDEPRECATED: use nbconvert)      z#Unsupported PY nbformat version: %i)r)   r   r   Zto_notebook_pyr   )r3   r4   r5   r6   r9   r%   r%   r&   r   S   s    c             K   s   t   td j| f|S )zDEPRECATED: use nbconvertr;   )r)   r   r   )r9   r4   r%   r%   r&   r   ]   s    
DEPRECATEDc          
   K   sf   |dkrt   t| f|}t||}yt| W n0 tk
r` } zt d| W dd}~X Y nX |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.
    >   jsonr<   zNotebook JSON is invalid: %sN)r)   reader_readsr   r   r   r   error)r3   formatversionr4   r9   er%   r%   r&   r   f   s    
 c          
   K   sh   |dkrt   t| |} yt|  W n0 tk
rT } zt d| W dd}~X Y nX t| j| f|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.
    >   r=   r<   zNotebook JSON is invalid: %sN)r)   r   r   r   r   r?   r   r   )r9   r@   rA   r4   rB   r%   r%   r&   r      s    
 c             K   s   t |  f|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@   r4   r%   r%   r&   r       s    c             K   s*   t | f|}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!   )r9   rC   r@   r4   r3   r%   r%   r&   r!      s    

)r<   )r<   )3__doc__Z
__future__r   r-   r'   r(   Znbformat.v3r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   Z	_v_latestreaderr   r>    r   Z	converterr   Z	validatorr   r   Ztraitlets.logr   __all__r+   r,   r"   Zcurrent_nbformat_module
ValueErrorr   r)   r   r   r   r   r   r   r    r!   r%   r%   r%   r&   <module>   s@   @


	
