o
    'h                     @   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   I/var/www/html/olx_land/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   '