
    f
                    D    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
y
)z8Code for converting notebooks to and from the v2 format.    )annotations   )nbformatnbformat_minorc                   t        | t              r(| j                         D ]  \  }}t        |      | |<    | S t        | t              r#t        |       D ]  \  }}t        |      | |<    | S t        | t              r| j                  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       N/var/www/cvtools/html/venv/lib/python3.12/site-packages/nbformat/v3/convert.pyr   r   
   s    
 #tIIK 	!DAqa[CF	! J 
C	cN 	!DAqa[CF	!
 J 
C	jj!J    c                   |dk(  rPt         | _         t        | _        d| _        t        |       } | d   D ]  }|d   D ]  }|j	                  di           | S |dk(  r|t        k7  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).
       
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\\" 	0B7 0
B/0	0 	q'%/B"*		13?	@  S/r   c                j    d| _         | j                  dd      }d|z  dz   | j                  z   | _        y)z-turn heading cell into corresponding markdownmarkdownlevelr   # N)	cell_typepopsource)r%   r*   s     r   heading_to_mdr0   >   s2    DNHHWa E+#dkk1DKr   c                    d| _         y)zlet raw passthrough as markdownr)   N)r-   )r%   s    r   	raw_to_mdr2   E   s	    DNr   c                    | j                   dk7  r| S d| _         | j                  D ]I  }|j                  D ]8  }|j                  dk(  rt	        |       |j                  dk(  s.t        |       : K | 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   sp     
{{a	BKmm  HH 	 D~~*d#5($		   Ir   N)r   r   )__doc__
__future__r   nbbaser   r   r   r'   r0   r2   r6    r   r   <module>r;      s*    > # ," F2 
r   