o
    ¹iŽ  ã                   @   sœ   d Z ddlZddlZddlmZ ddlmZmZmZm	Z	m
Z
 G dd„ dejƒZG dd	„ d	eƒZG d
d„ deƒZeƒ Zeƒ ZejZejZejZejZejZdS )z(Read and write notebooks in JSON format.é    Né   )Ú	from_dict)ÚNotebookReaderÚNotebookWriterÚrejoin_linesÚsplit_linesÚstrip_transientc                   @   ó   e Zd ZdZdd„ ZdS )ÚBytesEncoderz@A JSON encoder that accepts b64 (and other *ascii*) bytestrings.c                 C   s"   t |tƒr
| d¡S tj | |¡S )z#Get the default value of an object.Úascii)Ú
isinstanceÚbytesÚdecodeÚjsonÚJSONEncoderÚdefault)ÚselfÚobj© r   úM/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/nbformat/v3/nbjson.pyr      s   

zBytesEncoder.defaultN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r
      ó    r
   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )Ú
JSONReaderzA JSON notebook reader.c                 K   s0   t j|fi |¤Ž}| j|fi |¤Ž}t|ƒ}|S )zConvert a string to a notebook.)r   ÚloadsÚto_notebookr   )r   ÚsÚkwargsÚnbr   r   r   Úreads   s   zJSONReader.readsc                 K   s   t t|ƒƒS )zConvert a dict to a notebook.)r   r   )r   Údr   r   r   r   r   !   s   zJSONReader.to_notebookN)r   r   r   r   r!   r   r   r   r   r   r      s    r   c                   @   r	   )Ú
JSONWriterzA JSON notebook writer.c                 K   sX   t |d< d|d< d|d< d|d< t |¡}t|ƒ}| dd¡r#t|ƒ}tj|fi |¤ŽS )	zConvert a notebook to a string.Úclsr   ÚindentTÚ	sort_keys)ú,z: Ú
separatorsr   )r
   ÚcopyÚdeepcopyr   Úpopr   r   Údumps)r   r    r   r   r   r   Úwrites)   s   
zJSONWriter.writesN)r   r   r   r   r-   r   r   r   r   r#   &   r   r#   )r   r)   r   Únbbaser   Úrwbaser   r   r   r   r   r   r
   r   r#   Ú_readerÚ_writerr!   Úreadr   Úwriter-   r   r   r   r   Ú<module>   s    

