
    Mh
                    F    d Z ddlmZ ddlmZmZ d ZddZd Zd	 Z	d
 Z
dS )z8Code for converting notebooks to and from the v2 format.    )annotations   )nbformatnbformat_minorc                X   t          | t                    r-|                                 D ]\  }}t          |          | |<   ngt          | t                    r(t          |           D ]\  }}t          |          | |<   n*t          | t                    r|                     d          } | S )z^There should be no bytes objects in a notebook

    v2 stores png/jpeg as b64 ascii bytes
    ascii)
isinstancedictitems_unbyteslist	enumeratebytesdecode)objkvis       S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/nbformat/v3/convert.pyr   r   
   s    
 #t "IIKK 	! 	!DAqa[[CFF	!	C		 "cNN 	! 	!DAqa[[CFF	!	C		 "jj!!J       c                :   |dk    r\t           | _         t          | _        d| _        t          |           } | d         D ]#}|d         D ]}|                    di            $| S |dk    r |t          k    r|| _        t          | _        | S d|z  }t          |          )aP  Convert a notebook to v3.

    Parameters
    ----------
    nb : NotebookNode
        The Python representation of the notebook to convert.
    from_version : int
        The original version of the notebook to convert.
    from_minor : int
        The original minor version of the notebook to convert (only relevant for v >= 3).
    r   
worksheetscellsmetadata   zZCannot convert a notebook directly from v%s to v3.  Try using the nbformat.convert module.)r   r   orig_nbformatr   
setdefaultorig_nbformat_minor
ValueError)nbfrom_version
from_minorwscellmsgs         r   upgrader'      s     q*b\\\" 	0 	0B7 0 0
B////0	q''%/B"*		13?	@  S//r   c                j    d| _         |                     dd          }d|z  dz   | j        z   | _        dS )z-turn heading cell into corresponding markdownmarkdownlevelr   # N)	cell_typepopsource)r%   r*   s     r   heading_to_mdr0   >   s7    DNHHWa  E+#dk1DKKKr   c                    d| _         dS )zlet raw passthrough as markdownr)   N)r-   )r%   s    r   	raw_to_mdr2   E   s    DNNNr   c                    | j         dk    r| S d| _         | j        D ]A}|j        D ]7}|j        dk    rt	          |           |j        dk    rt          |           8B| S )zConvert a v3 notebook to v2.

    Parameters
    ----------
    nb : NotebookNode
        The Python representation of the notebook to convert.
    r   r   headingraw)r   r   r   r-   r0   r2   )r!   r$   r%   s      r   	downgrader6   J   s     
{a	BKm    H 	  	 D~**d####5(($		 
 Ir   N)r   r   )__doc__
__future__r   nbbaser   r   r   r'   r0   r2   r6    r   r   <module>r;      s    > > # " " " " " , , , , , , , ,  "       F2 2 2     
    r   