Ë
    :vžjV  ã                  ó  — d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	m
Z
mZ ddlmZmZ ddlmZ g d	¢Zee	e
ed
œ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lmZ ddlmZmZ  G d„ de «      Z! ede"d«      Z#dd„Z$e#dfd„Z%dd„Z&e#dfd„Z'y)znThe Jupyter notebook format

Use this module to read or write notebook files as particular nbformat versions.
é    )Úannotations)ÚPath)Ú
get_loggeré   )Úv1Úv2Úv3Úv4)Ú__version__Úversion_info)ÚSentinel)Ú
NO_CONVERTÚNBFormatErrorÚNotebookNoder   ÚValidationErrorr   ÚconvertÚcurrent_nbformatÚcurrent_nbformat_minorÚ	from_dictÚreadÚreadsÚvalidater   ÚversionsÚwriteÚwrites)r   é   é   é   )Úreader)r   )r   r   )Únbformat)Únbformat_minor)r   r   c                  ó   — e Zd Zy)r   N)Ú__name__Ú
__module__Ú__qualname__© ó    úb/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/nbformat/__init__.pyr   r   5   s   „ Ør'   r   r   zKValue to prevent nbformat to convert notebooks to most recent version.
    Nc                óþ   — t        j                  | fi |¤Ž}|t        urt        ||«      }	 t	        |«       |S # t
        $ r:}t        «       j                  d|«       t        |t        «      r||d<   Y d}~|S d}~ww xY w)a9  Read a notebook from a string and return the NotebookNode object as the given version.

    The string can contain a notebook of any version.
    The notebook will be returned `as_version`, converting, if necessary.

    Notebook format errors will be logged.

    Parameters
    ----------
    s : unicode
        The raw unicode string to read the notebook from.
    as_version : int
        The version of the notebook format to return.
        The notebook will be converted, if necessary.
        Pass nbformat.NO_CONVERT to prevent conversion.
    capture_validation_error : dict, optional
        If provided, a key of "ValidationError" with a
        value of the ValidationError instance will be added
        to the dictionary.

    Returns
    -------
    nb : NotebookNode
        The notebook that was read.
    úNotebook JSON is invalid: %sr   N)
r   r   r   r   r   r   r   ÚerrorÚ
isinstanceÚdict)ÚsÚ
as_versionÚcapture_validation_errorÚkwargsÚnbÚes         r(   r   r   B   s€   € ô4 
�‰�aÑ	"˜6Ñ	"€BØœÑ#Ü�R˜Ó$ˆð<Ü�Œð
 €Iøô	 ò <Ü‹×ÑÐ9¸1Ô=ÜÐ.´Ô5Ø:;Ð$Ð%6Ñ7ûØ€Iûð	<ús   ¬9 ¹	A<Á/A7Á7A<c                ó0  — |t         urt        | |«      } nt        j                  | «      \  }}	 t	        | «       t        |   j                  | fi |¤ŽS # t
        $ r9}t        «       j                  d|«       t        |t        «      r||d<   Y d}~ŒVd}~ww xY w)a¯  Write a notebook to a string in a given format in the given nbformat version.

    Any notebook format errors will be logged.

    Parameters
    ----------
    nb : NotebookNode
        The notebook to write.
    version : int, optional
        The nbformat version to write.
        If unspecified, or specified as nbformat.NO_CONVERT,
        the notebook's own version will be used and no conversion performed.
    capture_validation_error : dict, optional
        If provided, a key of "ValidationError" with a
        value of the ValidationError instance will be added
        to the dictionary.

    Returns
    -------
    s : unicode
        The notebook as a JSON string.
    r*   r   N)r   r   r   Úget_versionr   r   r   r+   r,   r-   r   Úwrites_json)r2   Úversionr0   r1   Ú_r3   s         r(   r   r   h   s’   € ð. ”jÑ Ü�R˜Ó!‰ä×'Ñ'¨Ó+‰
ˆ�ð<Ü�Œô
 �GÑ×(Ñ(¨Ñ6¨vÑ6Ð6øô	 ò <Ü‹×ÑÐ9¸1Ô=ÜÐ.´Ô5Ø:;Ð$Ð%6Ñ7ÿøð<ús   ¯A Á	BÁ/BÂBc                óà   — 	 | j                  «       }t        ||fi |¤ŽS # t        $ rD t        | d¬«      5 }t        |j                  «       ||fi |¤Žcddd«       cY S # 1 sw Y   nxY wY ŒZw xY w)ar  Read a notebook from a file as a NotebookNode of the given version.

    The string can contain a notebook of any version.
    The notebook will be returned `as_version`, converting, if necessary.

    Notebook format errors will be logged.

    Parameters
    ----------
    fp : file or str
        A file-like object with a read method that returns unicode (use
        ``io.open()`` in Python 2), or a path to a file.
    as_version : int
        The version of the notebook format to return.
        The notebook will be converted, if necessary.
        Pass nbformat.NO_CONVERT to prevent conversion.
    capture_validation_error : dict, optional
        If provided, a key of "ValidationError" with a
        value of the ValidationError instance will be added
        to the dictionary.

    Returns
    -------
    nb : NotebookNode
        The notebook that was read.
    Úutf8©ÚencodingN)r   ÚAttributeErrorÚopenr   )Úfpr/   r0   r1   ÚbufÚfs         r(   r   r   Œ   sp   € ð8SØ�g‰g‹iˆô
 ��jÐ":ÑE¸fÑEÐEøô	 ò SÜ�"˜vÕ&¨!Ü˜Ÿ™› :Ð/GÑRÈ6ÑR÷ '×&Ô&úÑ&ðSús&   ‚   A-¶AÁ
A-ÁA'	Á#A-Á,A-c                ó´  — t        | ||fi |¤Ž}t        |t        «      r|j                  d«      }	 |j	                  |«       |j                  d«      s|j	                  d«       yy# t        $ rh t        |«      j                  dd¬«      5 }|j	                  |«       |j                  d«      s|j	                  d«       ddd«       Y y# 1 sw Y   Y yxY ww xY w)a  Write a notebook to a file in a given nbformat version.

    The file-like object must accept unicode input.

    Parameters
    ----------
    nb : NotebookNode
        The notebook to write.
    fp : file or str
        Any file-like object with a write method that accepts unicode, or
        a path to write a file.
    version : int, optional
        The nbformat version to write.
        If nb is not this version, it will be converted.
        If unspecified, or specified as nbformat.NO_CONVERT,
        the notebook's own version will be used and no conversion performed.
    capture_validation_error : dict, optional
        If provided, a key of "ValidationError" with a
        value of the ValidationError instance will be added
        to the dictionary.
    r:   Ú
Úwr;   N)	r   r,   ÚbytesÚdecoder   Úendswithr=   r   r>   )r2   r?   r7   r0   r1   r.   rA   s          r(   r   r   ±   s¯   € ô, 	ˆr�7Ð4Ñ?¸Ñ?€AÜ�!”UÔØ�H‰H�VÓˆðØ
�‰�ŒØ�z‰z˜$ÔØ�H‰H�T�Nð  øäò Ü�"‹X�]‰]˜3¨ˆ]Ô0°AØ�G‰G�AŒJØ—:‘:˜dÔ#Ø—‘˜”÷ 1×0Ó0úðús)   ±3A& Á&%CÂ4C	Â?CÃ	C	ÃCÃC)N)(Ú__doc__Ú
__future__r   Úpathlibr   Útraitlets.logr   Ú r   r   r	   r
   Ú_versionr   r   Úsentinelr   Ú__all__r   r   Ú	converterr   Únotebooknoder   r   r    r   r!   r   Ú	validatorr   r   Ú
ValueErrorr   r#   r   r   r   r   r   r&   r'   r(   Ú<module>rT      sš   ðñõ #å å $ç Ó ß /Ý ò€ð* 
Ø	Ø	Ø	ñ	€õ Ý ß 1Ý ,Ý 8ß 0ô	�Jô 	ñ
 ØØðó€
ó#ðL "¸Dó !7óH"FðJ %¸tô "r'   