Ë
    :vžj�
  ã                  óV   — d Z ddlmZ ddlZddlmZ  G d„ de«      Zd„ Zd	„ Z	d
„ Z
d„ Zy)z/API for reading notebooks of different versionsé    )ÚannotationsNé   )ÚValidationErrorc                  ó   — e Zd ZdZy)ÚNotJSONErrorz1An error raised when an object is not valid JSON.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    ú`/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/nbformat/reader.pyr   r      s   „ Ú;r   r   c                ó¤   — 	 t        j                  | fi |¤Ž}|S # t        $ r,}d| ›�}t        |«      dkD  r|dd dz   }t	        |«      |‚d}~ww xY w)z Parse a JSON string into a dict.z%Notebook does not appear to be JSON: éP   NéM   z...)ÚjsonÚloadsÚ
ValueErrorÚlenr   )ÚsÚkwargsÚnb_dictÚeÚmessages        r   Ú
parse_jsonr      sh   € ð+Ü—*‘*˜QÑ) &Ñ)ˆð €Nøô ò +Ø9¸!¸Ð?ˆäˆw‹<˜"ÒØ˜c˜r�l UÑ*ˆGÜ˜7Ó#¨Ð*ûð+ús   ‚ š	A£'A
Á
Ac                óR   — | j                  dd«      }| j                  dd«      }||fS )záGet 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/   € ð �F‰F�:˜qÓ!€EØ�F‰FÐ# QÓ'€EØ�5ˆ>Ðr   c                óÖ   — ddl m}m} t        | fi |¤Ž}t	        |«      \  }}||v r	 ||   j                  ||¬«      S  |d|z  «      ‚# t        $ r}d|› �}t        |«      d‚d}~ww xY w)aQ  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Ü  Ó)�N€UˆEØ�Ñð	1Ø˜E‘?×3Ñ3°GÀ5Ð3ÓIÐIñ
 Ð=ÀÑEÓFÐFøô	 ò 	1ØLÈQÈCÐPˆCÜ! #Ó&¨DÐ0ûð	1ús   ¨A	 Á		A(ÁA#Á#A(c                ó6   — t        | j                  «       fi |¤ŽS )aZ  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   r-   r-   W   s   € ô  �—‘“Ñ%˜fÑ%Ð%r   )r   Ú
__future__r   r   Ú	validatorr   r   r   r   r#   r+   r-   r   r   r   Ú<module>r1      s5   ðÙ 5õ #ã å &ô<�:ô <ò
ò ò"#GóL&r   