
    e*
                     :    d 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.   )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       3lib/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				''%/B"*	57CD 	 oo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_mdr/   >   s7    DNHHWa  E+#dk1DKKKr   c                     d| _         dS )zlet raw passthrough as markdownr(   N)r,   )r$   s    r   	raw_to_mdr1   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,   r/   r1   )r    r#   r$   s      r   	downgrader5   J   s     
{a	BKm    H 	  	 D~**d####5(($		 
 Ir   N)r   r   )	__doc__nbbaser   r   r
   r&   r/   r1   r5    r   r   <module>r9      s    > >
 - , , , , , , ,  "! ! ! !H2 2 2     
    r   