ó
‹'=[c           @   sB  d  Z  d d l Z d d l Z d d l m Z d d l m Z m Z d Z d Z	 d Z
 d e f d	 „  ƒ  YZ d
 „  Z d d d d d d d d d d d d d d d „ Z d d d d e d d „ Z d d d d „ Z d d d d d „ Z d d d d „ Z d d d d „ Z d d d d d d d „ Z d d d d d „ Z d S(   s  The basic dict based notebook format.

The Python representation of a notebook is a nested structure of
dictionary subclasses that support attribute access
(ipython_genutils.ipstruct.Struct). The functions in this module are merely
helpers to build the structs in the right form.
iÿÿÿÿN(   t   Struct(   t   cast_unicodet   unicode_typei   i    s   nbformat.v3.schema.jsont   NotebookNodec           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s1   lib/python2.7/site-packages/nbformat/v3/nbbase.pyR      s   c         C   sƒ   t  |  t ƒ rI t ƒ  } x* |  j ƒ  D] \ } } t | ƒ | | <q% W| St  |  t t f ƒ r{ g  |  D] } t | ƒ ^ qe S|  Sd  S(   N(   t
   isinstancet   dictR   t   itemst	   from_dictt   tuplet   list(   t   dt   newdt   kt   vt   i(    (    s1   lib/python2.7/site-packages/nbformat/v3/nbbase.pyR	      s    	c         C   sK  t  ƒ  } t |  ƒ | _ | d k r- i  } n  t | t ƒ sK t d ƒ ‚ n  |  d d h k ri | | _ n  |  d k rh| d k	 r“ t | ƒ | _	 n  | d k	 r± t | ƒ | _
 n  | d k	 rÏ t | ƒ | _ n  | d k	 rí t | ƒ | _ n  | d k	 rt | ƒ | _ n  | d k	 r)t | ƒ | _ n  | d k	 rGt | ƒ | _ n  | d k	 rht | ƒ | _ qhn  |  d k r•|	 d k	 r•t |	 ƒ | _ q•n  |  d k r|
 d k	 r¿t |
 ƒ | _ n  | d k	 rÝt | ƒ | _ n  | d k	 rg  t | ƒ D] } t | ƒ ^ qö| _ qn  |  d k rG| d k r5d n	 t | ƒ | _ n  | S(	   sL   Create a new output, to go in the ``cell.outputs`` list of a code cell.
    s   metadata must be dictu   pyoutt   display_datat   pyerru   pyerru   streamt   stdoutN(   R   R   t   output_typet   NoneR   R   t	   TypeErrort   metadataR   t   textt   pngt   jpegt   htmlt   svgt   latext   jsont
   javascriptt   intt   prompt_numbert   enamet   evalueR   t	   tracebackt   stream(   R   t   output_textt
   output_pngt   output_htmlt
   output_svgt   output_latext   output_jsont   output_javascriptt   output_jpegR!   R"   R#   R$   R%   R   t   outputt   frame(    (    s1   lib/python2.7/site-packages/nbformat/v3/nbbase.pyt
   new_output+   sL    		.$u   pythonc         C   sÄ   t  ƒ  } d | _ | d k	 r0 t | ƒ | _ n  |  d k	 rN t |  ƒ | _ n  | d k	 rl t | ƒ | _ n  | d k r„ g  | _ n	 | | _ | d k	 r« t	 | ƒ | _
 n  t  | p· i  ƒ | _ | S(   s,   Create a new code cell with input and outputu   codeN(   R   t	   cell_typeR   R   t   languaget   inputR    R!   t   outputst   boolt	   collapsedR   (   R3   R!   R4   R2   R6   R   t   cell(    (    s1   lib/python2.7/site-packages/nbformat/v3/nbbase.pyt   new_code_cella   s    			c         C   s^   t  ƒ  } |  d k r d }  n  | d k	 r< t | ƒ | _ n  t  | pH i  ƒ | _ |  | _ | S(   s   Create a new text cell.t	   plaintextt   rawN(   R   R   R   t   sourceR   R1   (   R1   R;   t   renderedR   R7   (    (    s1   lib/python2.7/site-packages/nbformat/v3/nbbase.pyt   new_text_cellv   s    			i   c         C   sX   t  ƒ  } d | _ |  d k	 r0 t |  ƒ | _ n  t | ƒ | _ t  | pK i  ƒ | _ | S(   s5   Create a new section cell with a given integer level.u   headingN(   R   R1   R   R   R;   R    t   levelR   (   R;   R>   R<   R   R7   (    (    s1   lib/python2.7/site-packages/nbformat/v3/nbbase.pyt   new_heading_cell„   s    		c         C   sI   t  ƒ  } | d k r! g  | _ n t | ƒ | _ t  | p< i  ƒ | _ | S(   s5   Create a worksheet by name with with a list of cells.N(   R   R   t   cellsR   R   (   t   nameR@   R   t   ws(    (    s1   lib/python2.7/site-packages/nbformat/v3/nbbase.pyt   new_worksheet   s    	c         C   s‘   t  ƒ  } t | _ t | _ | d k r3 g  | _ n t | ƒ | _ | d k r] t ƒ  | _ n t  | ƒ | _ |  d k	 r t |  ƒ | j _	 n  | S(   s7   Create a notebook by name, id and a list of worksheets.N(
   R   t   nbformatt   nbformat_minorR   t
   worksheetsR   t   new_metadataR   R   RA   (   RA   R   RF   t   nb(    (    s1   lib/python2.7/site-packages/nbformat/v3/nbbase.pyt   new_notebookš   s    			c         C   sÁ   t  ƒ  } |  d k	 r' t |  ƒ | _ n  | d k	 rE t | ƒ | _ n  | d k	 rc t | ƒ | _ n  | d k	 r t | ƒ | _ n  | d k	 rŸ t | ƒ | _ n  | d k	 r½ t | ƒ | _	 n  | S(   s   Create a new metadata node.N(
   R   R   R   RA   R   t   authorst   createdt   modifiedt   licenset   gistid(   RA   RJ   RM   RK   RL   RN   R   (    (    s1   lib/python2.7/site-packages/nbformat/v3/nbbase.pyRG   ¬   s    	c         C   s…   t  ƒ  } |  d k	 r' t |  ƒ | _ n  | d k	 rE t | ƒ | _ n  | d k	 rc t | ƒ | _ n  | d k	 r t | ƒ | _ n  | S(   s   Create a new author.N(   R   R   R   RA   t   emailt   affiliationt   url(   RA   RO   RP   RQ   t   author(    (    s1   lib/python2.7/site-packages/nbformat/v3/nbbase.pyt
   new_author¾   s    	(   t   __doc__t   pprintt   uuidt   ipython_genutils.ipstructR    t   ipython_genutils.py3compatR   R   RD   RE   t   nbformat_schemaR   R	   R   R0   t   FalseR8   R=   R?   RC   RI   RG   RS   (    (    (    s1   lib/python2.7/site-packages/nbformat/v3/nbbase.pyt   <module>   s,   		3	