
    UdZ                     <    d Z ddlmZ ddlmZ  G d de      Zd Zy)	z/NotebookNode - adding attribute access to dicts    )Mapping   )Structc                   (     e Zd ZdZ fdZd Z xZS )NotebookNodez&A dict-like node with attribute-accessc                 |    t        |t              rt        |t              st        |      }t        |   ||       y)zSet an item on the notebook.N)
isinstancer   r   	from_dictsuper__setitem__)selfkeyvalue	__class__s      7/usr/lib/python3/dist-packages/nbformat/notebooknode.pyr   zNotebookNode.__setitem__   s/    eW%j.Me$EC'    c                 ,   t        |      dkD  rt        dt        |      z        |rP|d   }t        |t              r|D ]
  }||   | |<    n+t	        |d      r|D ]
  }||   | |<    n|D ]
  \  }}|| |<    |j                         D ]
  \  }}|| |<    y)zf
        A dict-like update method based on CPython's MutableMapping `update`
        method.
        r   z+update expected at most 1 arguments, got %dr   keysN)len	TypeErrorr	   r   hasattritems)r   argskwargsotherr   r   s         r   updatezNotebookNode.update   s    
 t9q=ICPTIUVVGE%)  +C %c
DI+'  +C %c
DI+ #( &JC %DI& ,,. 	JCDI	r   )__name__
__module____qualname____doc__r   r   __classcell__)r   s   @r   r   r      s    0(r   r   c           
         t        | t              r6t        | j                         D ci c]  \  }}|t	        |       c}}      S t        | t
        t        f      r| D cg c]  }t	        |       c}S | S c c}}w c c}w )zConvert dict to dict-like NotebookNode

    Recursively converts any dict in the container to a NotebookNode.
    This does not check that the contents of the dictionary make a valid
    notebook or part of a notebook.
    )r	   dictr   r   r
   tuplelist)dkvis       r   r
   r
   '   sg     !TCAQ	!_CDD	At}	%&'(	!((	 D(s   A8
!A>N)r    collections.abcr   _structr   r   r
    r   r   <module>r-      s    5 # 6 >r   