o
    Þý°já  ã                   @   sR   d dl Zd dlmZmZ d dlmZ eG dd„ dejjƒƒZ	dedefdd	„Z
dS )
é    N)ÚAnyÚCallable)Ú	immutablec                	   @   sT   e Zd Zdefdededeg ejj	f fdd„Z
dd„ Zd	d
„ Zdd„ Zdd„ ZdS )ÚDictFÚ
dictionaryÚno_copyÚmap_factoryc                 C   s8   |rt |tjjƒr|| _n
|ƒ | _| j |¡ d| _dS )a  Make an immutable dictionary from the specified dictionary.

        If *no_copy* is `True`, then *dictionary* will be wrapped instead
        of copied.  Only set this if you are sure there will be no external
        references to the dictionary.
        N)Ú
isinstanceÚcollectionsÚabcÚMutableMappingÚ_odictÚupdateÚ_hash)Úselfr   r   r   © r   ú€/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/dns/immutable.pyÚ__init__   s
   
zDict.__init__c                 C   s   | j  |¡S ©N)r   Ú__getitem__)r   Úkeyr   r   r   r      s   zDict.__getitem__c                 C   sB   | j d u rd}t| j ¡ ƒD ]}|t|ƒN }qt | d|¡ | j S )Nr   r   )r   Úsortedr   ÚkeysÚhashÚobjectÚ__setattr__)r   Úhr   r   r   r   Ú__hash__!   s   
zDict.__hash__c                 C   ó
   t | jƒS r   )Úlenr   ©r   r   r   r   Ú__len__*   ó   
zDict.__len__c                 C   r   r   )Úiterr   r    r   r   r   Ú__iter__-   r"   zDict.__iter__N)Ú__name__Ú
__module__Ú__qualname__Údictr   Úboolr   r
   r   r   r   r   r   r!   r$   r   r   r   r   r   	   s    üþý
ü	r   ÚoÚreturnc                 C   s¨   t | tƒr	t| ƒS t | tƒr(zt| ƒ | W S  ty'   tdd„ | D ƒƒ Y S w t | tƒr6tdd„ | D ƒƒS t | tƒrRtƒ }|  ¡ D ]
\}}t	|ƒ||< qBt
|dƒS | S )z3
    Convert mutable types to immutable types.
    c                 s   ó   � | ]}t |ƒV  qd S r   ©Úconstify©Ú.0Úeltr   r   r   Ú	<genexpr><   ó   € zconstify.<locals>.<genexpr>c                 s   r,   r   r-   r/   r   r   r   r2   >   r3   T)r	   Ú	bytearrayÚbytesÚtupler   Ú	ExceptionÚlistr(   Úitemsr.   r   )r*   ÚcdictÚkÚvr   r   r   r.   1   s"   

ÿ


r.   )Úcollections.abcr
   Útypingr   r   Údns._immutable_ctxr   r   ÚMappingr   r.   r   r   r   r   Ú<module>   s   '