
    Ud*
                     8    d 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.   )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       5/usr/lib/python3/dist-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 			'%/B"*	57CD 	 o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_mdr.   >   s2    DNHHWa E+#dkk1DKr   c                     d| _         y)zlet raw passthrough as markdownr'   N)r+   )r#   s    r   	raw_to_mdr0   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+   r.   r0   )r   r"   r#   s      r   	downgrader4   J   sp     
{{a	BKmm  HH 	 D~~*d#5($		   Ir   N)r       )	__doc__nbbaser   r   r
   r%   r.   r0   r4    r   r   <module>r9      s'    >
 -"!H2 
r   