
    Eh
                    V    S r SSKJr  SSKrSSKJr   " S S\5      rS rS	 r	S
 r
S rg)z/API for reading notebooks of different versions    )annotationsN   )ValidationErrorc                      \ rS rSrSrSrg)NotJSONError   z1An error raised when an object is not valid JSON. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r	       bC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\nbformat/reader.pyr   r      s    ;r   r   c                     [         R                  " U 40 UD6nU$ ! [         a.  nSU < 3n[        U5      S:  a  USS S-   n[	        U5      UeSnAff = f)z Parse a JSON string into a dict.z%Notebook does not appear to be JSON: P   NM   z...)jsonloads
ValueErrorlenr   )skwargsnb_dictemessages        r   
parse_jsonr      sh    +**Q)&) N  +9!?w<"crlU*G7#*+s    
A)AAc                P    U R                  SS5      nU R                  SS5      nX4$ )zGet the version of a notebook.

Parameters
----------
nb : dict
    NotebookNode or dict containing notebook data.

Returns
-------
Tuple containing major (int) and minor (int) version numbers
nbformatr   nbformat_minorr   )get)nbmajorminors      r   get_versionr&       s-     FF:q!EFF#Q'E>r   c                    SSK JnJn  [        U 40 UD6n[	        U5      u  pVXS;   a   X5   R                  XFS9$ U" SU-  5      e! [         a  nSU 3n[        U5      SeSnAff = f)a	  Read a notebook from a json string and return the
NotebookNode object.

This function properly reads notebooks of any version.  No version
conversion is performed.

Parameters
----------
s : unicode | bytes
    The raw string or bytes object to read the notebook from.

Returns
-------
nb : NotebookNode
    The notebook that was read.

Raises
------
ValidationError
    Notebook JSON for a given version is missing an expected key and cannot be read.
NBFormatError
    Specified major version is invalid or unsupported.
r   )NBFormatErrorversions)r%   z8The notebook is invalid and is missing an expected key: NzUnsupported nbformat version %s) r(   r)   r   r&   to_notebook_jsonAttributeErrorr   )	r   r   r(   r)   r   r$   r%   r   msgs	            r   readsr.   1   s    0 *%f%G )NU	1?33G3II
 =EFF	  	1LQCPC!#&D0	1s   A 
A$AA$c                6    [        U R                  5       40 UD6$ )a.  Read a notebook from a file and return the NotebookNode object.

This function properly reads notebooks of any version.  No version
conversion is performed.

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

Returns
-------
nb : NotebookNode
    The notebook that was read.
)r.   read)fpr   s     r   r0   r0   W   s      %f%%r   )r   
__future__r   r   	validatorr   r   r   r   r&   r.   r0   r	   r   r   <module>r4      s5    5 #  &<: <
 "#GL&r   