U
    <æ{fá  ã                   @   sP   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	eedœdd„Z
dS )	é    N)ÚAnyÚCallable)Ú	immutablec                   @   sP   e Zd Zdefeeeg ejj	f dœ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   úL/var/www/html/Darija-Ai-API/env/lib/python3.8/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 k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   s
   t | jƒS r   )Úlenr   ©r   r   r   r   Ú__len__*   s    zDict.__len__c                 C   s
   t | jƒS r   )Úiterr   r   r   r   r   Ú__iter__-   s    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ƒrRzt| ƒ | W S  tk
rP   tdd„ | D ƒƒ Y S X t | tƒrntdd„ | D ƒƒS t | tƒr¦tƒ }|  ¡ D ]\}}t	|ƒ||< q†t
|dƒS | S )z3
    Convert mutable types to immutable types.
    c                 s   s   | ]}t |ƒV  qd S r   ©Úconstify©Ú.0Úeltr   r   r   Ú	<genexpr><   s     zconstify.<locals>.<genexpr>c                 s   s   | ]}t |ƒV  qd S r   r*   r,   r   r   r   r/   >   s     T)r	   Ú	bytearrayÚbytesÚtupler   Ú	ExceptionÚlistr&   Úitemsr+   r   )r(   ZcdictÚkÚvr   r   r   r+   1   s     




r+   )Úcollections.abcr
   Útypingr   r   Zdns._immutable_ctxr   r   ÚMappingr   r+   r   r   r   r   Ú<module>   s
   '