o
    ¹iY  ã                   @   s8   d Z ddlmZ ddlmZ G dd„ deƒZdd„ Zd	S )
z/NotebookNode - adding attribute access to dictsé    )ÚMappingé   )ÚStructc                       s(   e Zd ZdZ‡ fdd„Zdd„ Z‡  ZS )ÚNotebookNodez&A dict-like node with attribute-accessc                    s.   t |tƒrt |tƒst|ƒ}tƒ  ||¡ dS )zSet an item on the notebook.N)Ú
isinstancer   r   Ú	from_dictÚsuperÚ__setitem__)ÚselfÚkeyÚvalue©Ú	__class__© úP/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/nbformat/notebooknode.pyr	      s   zNotebookNode.__setitem__c                 O   s¤   t |ƒdkrtdt |ƒ ƒ‚|rC|d }t|tƒr%|D ]}|| | |< qnt|dƒr8| ¡ D ]}|| | |< q.n|D ]\}}|| |< q:| ¡ D ]\}}|| |< qGdS )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   Úhasattrr   Úitems)r
   ÚargsÚkwargsÚotherr   r   r   r   r   Úupdate   s"   
ÿ
ÿ

ÿzNotebookNode.update)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   Ú__classcell__r   r   r   r   r      s    r   c                 C   s@   t | tƒrtdd„ |  ¡ D ƒƒS t | ttfƒrdd„ | D ƒS | S )zßConvert 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.
    c                 S   s   i | ]	\}}|t |ƒ“qS r   ©r   )Ú.0ÚkÚvr   r   r   Ú
<dictcomp>/   s    zfrom_dict.<locals>.<dictcomp>c                 S   s   g | ]}t |ƒ‘qS r   r   )r    Úir   r   r   Ú
<listcomp>1   s    zfrom_dict.<locals>.<listcomp>)r   Údictr   r   ÚtupleÚlist)Údr   r   r   r   '   s
   
r   N)r   Úcollections.abcr   Ú_structr   r   r   r   r   r   r   Ú<module>   s
    