o
    2c                     @   sh   d dl Zd dlZejdkreZd dlmZ nd dlmZ d dl	mZ eG dd dej
jZdd ZdS )	    N)      )	immutable)OrderedDictc                   @   s6   e Zd ZdddZdd Zdd Zdd	 Zd
d ZdS )DictFc                 C   s*   |rt |tr|| _nt|| _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odict_odict_hash)self
dictionaryno_copy r   C/var/www/html/gps/gps/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)F)__name__
__module____qualname__r   r   r   r   r!   r   r   r   r   r      s    
	r   c                 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   r+   @   r,   T)r   	bytearraybytestupler   	Exceptionlistdictr   itemsr'   r   )ocdictkvr   r   r   r'   3   s"   




r'   )collections.abccollectionssysversion_infor2   r   dns._immutable_ctxr   r   dns._immutable_attrabcMappingr   r'   r   r   r   r   <module>   s   
!