ó
‹'=[c           @   sG   d  Z  d d l m Z m Z m Z m Z m Z d d „ Z d „  Z d S(   sh   Code for converting notebooks to and from the v2 format.

Authors:

* Brian Granger
* Jonathan Frederic
i   (   t   new_code_cellt   new_text_cellt   new_worksheett   new_notebookt
   new_outputc         C   sÐ   | d k r¼ t  ƒ  } t ƒ  } x‡ |  j D]| } | j d k rg t d | j d ƒ d | j d ƒ ƒ } n- | j d k r” t d d | j d	 ƒ ƒ} n  | j j | ƒ q( W| j j | ƒ | St	 d
 | ƒ ‚ d S(   sè   Convert a notebook to the v2 format.

    Parameters
    ----------
    nb : NotebookNode
        The Python representation of the notebook to convert.
    from_version : int
        The version of the notebook to convert from.
    i   u   codet   inputt   codet   prompt_numberu   textu   markdownt   sourcet   texts(   Cannot convert a notebook from v%s to v2N(
   R   R   t   cellst	   cell_typeR    t   getR   t   appendt
   worksheetst
   ValueError(   t   nbt   from_versiont   newnbt   wst   cellt   newcell(    (    s2   lib/python2.7/site-packages/nbformat/v2/convert.pyt   upgrade   s    
		*c         C   s   t  d ƒ ‚ d S(   s”   Convert a v2 notebook to v1.

    Parameters
    ----------
    nb : NotebookNode
        The Python representation of the notebook to convert.
    s2   Downgrade from notebook v2 to v1 is not supported.N(   t	   Exception(   R   (    (    s2   lib/python2.7/site-packages/nbformat/v2/convert.pyt	   downgrade5   s    N(	   t   __doc__t   nbbaseR    R   R   R   R   R   R   (    (    (    s2   lib/python2.7/site-packages/nbformat/v2/convert.pyt   <module>   s   (