ó
‹'=[c           @   sz   d  Z  d d l m Z d Z d Z d Z d d „ Z d d „ Z d „  Z	 d d	 „ Z
 d d
 „ Z d d „ Z d „  Z d S(   s  Python API for composing notebook elements

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   (   t   NotebookNodei   s   nbformat.v4.schema.jsonc         C   s&   d d l  m } | |  d | d t ƒS(   s   validate a v4 nodei   (   t   validatet   reft   version(   t    R   t   nbformat(   t   nodeR   R   (    (    s1   lib/python2.7/site-packages/nbformat/v4/nbbase.pyR      s    c         K   s“   t  d |  ƒ } |  d k r0 d | _ d | _ n- |  d d h k r] t  ƒ  | _ t  ƒ  | _ n  | j | ƒ | d k	 r‚ | | _ n  t | |  ƒ | S(   sG   Create a new output, to go in the ``cell.outputs`` list of a code cell.t   output_typet   streamu   stdoutu    t   execute_resultt   display_dataN(   R    t   namet   textt   metadatat   datat   updatet   NoneR   (   R   R   t   kwargst   output(    (    s1   lib/python2.7/site-packages/nbformat/v4/nbbase.pyt
   new_output   s    	c      
   C   sô   |  d d } |  d } | d k rO t  d | d | d d | d d | d ƒ S| d	 k r| t  d | d
 | d
 d | d ƒ S| d k r© t  d | d | d d | d ƒ S| d k rà t  d | d | d d | d d | d ƒ St d | ƒ ‚ d S(   sä   Create a NotebookNode for an output from a kernel's IOPub message.

    Returns
    -------

    NotebookNode: the output as a notebook node.

    Raises
    ------

    ValueError: if the message is not an output message.

    t   headert   msg_typet   contentR	   R   R   R   t   execution_countR   R   R   R
   t   errort   enamet   evaluet	   tracebacks    Unrecognized output msg type: %rN(   R   t
   ValueError(   t   msgR   R   (    (    s1   lib/python2.7/site-packages/nbformat/v4/nbbase.pyt   output_from_msg.   s*    






R   c         K   sH   t  d d d t  ƒ  d d d |  d g  ƒ } | j | ƒ t | d ƒ | S(	   s   Create a new code cellt	   cell_typet   codeR   R   t   sourcet   outputst	   code_cellN(   R    R   R   R   (   R!   R   t   cell(    (    s1   lib/python2.7/site-packages/nbformat/v4/nbbase.pyt   new_code_cellY   s    		c         K   s<   t  d d d |  d t  ƒ  ƒ } | j | ƒ t | d ƒ | S(   s   Create a new markdown cellR   t   markdownR!   R   t   markdown_cell(   R    R   R   (   R!   R   R$   (    (    s1   lib/python2.7/site-packages/nbformat/v4/nbbase.pyt   new_markdown_cellg   s    c         K   s<   t  d d d |  d t  ƒ  ƒ } | j | ƒ t | d ƒ | S(   s   Create a new raw cellR   t   rawR!   R   t   raw_cell(   R    R   R   (   R!   R   R$   (    (    s1   lib/python2.7/site-packages/nbformat/v4/nbbase.pyt   new_raw_cells   s    c       	   K   s?   t  d t d t d t  ƒ  d g  ƒ } | j |  ƒ t | ƒ | S(   s   Create a new notebookR   t   nbformat_minorR   t   cells(   R    R   R,   R   R   (   R   t   nb(    (    s1   lib/python2.7/site-packages/nbformat/v4/nbbase.pyt   new_notebook   s    		
N(   t   __doc__t   notebooknodeR    R   R,   t   nbformat_schemaR   R   R   R   R%   R(   R+   R/   (    (    (    s1   lib/python2.7/site-packages/nbformat/v4/nbbase.pyt   <module>   s   	+