
    ^h                        S r SSKJr  SSKJr  SSKJr  SrSr	SSS	S
SSSS.r
SS jrSS jrS rSS jrSS jrSS jrS rg)zPython API for composing notebook elements

The Python representation of a notebook is a nested structure of
dictionary subclasses that support attribute access.
The functions in this module are merely helpers to build the structs
in the right form.
    )annotations)generate_corpus_id)NotebookNode      znbformat.v4.schema.jsonznbformat.v4.0.schema.jsonznbformat.v4.1.schema.jsonznbformat.v4.2.schema.jsonznbformat.v4.3.schema.jsonznbformat.v4.4.schema.jsonznbformat.v4.5.schema.json))NN)r   r   )r      )r      )r      )r   r   )r   r   Nc                $    SSK Jn  U" X[         S9$ )zvalidate a v4 noder   )validate)refversion)nbformatr   )noder   validate_origs      L/home/james-whalen/.local/lib/python3.13/site-packages/nbformat/v4/nbbase.pyr   r   %   s    299    c                d   [        U S9nU S:X  a  SUl        SUl        OlU S:X  a  [        5       Ul        [        5       Ul        OGU S:X  a&  [        5       Ul        [        5       Ul        SUl        OU S:X  a  S	Ul        SUl        / Ul        UR                  U5        Ub  Xl        [        X05        U$ )
zGCreate a new output, to go in the ``cell.outputs`` list of a code cell.)output_typestreamstdout display_dataexecute_resultNerrorNotImplementedError)r   nametextmetadatadataexecution_countenameevalue	tracebackupdater   )r   r    kwargsoutputs       r   
new_outputr(   ,   s    k2F h		&&."n	(	(&."n!%		, MM&V!Mr   c                    U S   S   nU S   nUS:X  a  [        UUS   US   US   S9$ US	:X  a  [        UUS
   US   S9$ US:X  a  [        UUS   US   S9$ US:X  a  [        UUS   US   US   S9$ [        SU-  5      e)zCreate 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.

headermsg_typecontentr   r   r    r!   )r   r   r    r!   r   r   r   )r   r   r   r   )r   r   r    r   r"   r#   r$   )r   r"   r#   r$   z Unrecognized output msg type: %r)r(   
ValueError)msgr+   r,   s      r   output_from_msgr/   I   s     8}Z(H)nG## Z(#$56	
 	
 8 
 	

 >! Z(
 	

 7 '"8$k*	
 	
 7(B
CCr   c           	     |    [        [        5       S[        5       SU / S9nUR                  U5        [        US5        U$ )zCreate a new code cellcodeN)id	cell_typer   r!   sourceoutputs	code_cellr   random_cell_idr%   r   r4   r&   cells      r   new_code_cellr;   u   s@    D 	KKT;Kr   c                x    [        [        5       SU [        5       S9nUR                  U5        [        US5        U$ )zCreate a new markdown cellmarkdownr2   r3   r4   r   markdown_cellr7   r9   s      r   new_markdown_cellr@      s:    	D 	KKT?#Kr   c                x    [        [        5       SU [        5       S9nUR                  U5        [        US5        U$ )zCreate a new raw cellrawr>   raw_cellr7   r9   s      r   new_raw_cellrD      s:    	D 	KKT:Kr   c                 v    [        [        [        [        5       / S9nUR                  U 5        [	        U5        U$ )zCreate a new notebook)r   nbformat_minorr   cells)r   r   rF   r%   r   )r&   nbs     r   new_notebookrI      s4    	%	
B IIfRLIr   )N)r   )__doc__
__future__r   nbformat.corpus.wordsr   r8   nbformat.notebooknoder   r   rF   nbformat_schemar   r(   r/   r;   r@   rD   rI    r   r   <module>rP      sf    # F .   ,''''''::)DX 
r   