HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/dns/__pycache__/namedict.cpython-310.pyc
o

!we��@s,dZddlmZddlZGdd�de�ZdS)zDNS name dictionary�)�MutableMappingNcsheZdZdZgd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
�ZS)�NameDictz�A dictionary whose keys are dns.name.Name objects.

    In addition to being like a regular Python dictionary, this
    dictionary can also get the deepest match for a given key.
    )�	max_depth�max_depth_items�__storecs6t���t�|_d|_d|_|�t|i|���dS)Nr)�super�__init__�dict�_NameDict__storerr�update)�self�args�kwargs��	__class__��E/home/arjun/projects/env/lib/python3.10/site-packages/dns/namedict.pyr-s

zNameDict.__init__cCsDt|�|jkr|jd|_dSt|�|jkr t|�|_d|_dSdS)N�)�lenrr�r�keyrrr�__update_max_depth6s

�zNameDict.__update_max_depthcCs
|j|S�N�r
rrrr�__getitem__=�
zNameDict.__getitem__cCs.t|tjj�std��||j|<|�|�dS)NzNameDict key must be a name)�
isinstance�dns�name�Name�
ValueErrorr
�_NameDict__update_max_depth)rr�valuerrr�__setitem__@s
zNameDict.__setitem__cCsT|j�|�t|�|jkr|jd|_|jdkr&d|_|jD]	}|�|�qdSdS)Nrr)r
�poprrrr!)rr�krrr�__delitem__Fs

�zNameDict.__delitem__cC�
t|j�Sr)�iterr
�rrrr�__iter__OrzNameDict.__iter__cCr'r)rr
r)rrr�__len__RrzNameDict.__len__cCs
||jvSrrrrrr�has_keyUrzNameDict.has_keycCsnt|�}||jkr|j}t|d�D]}tj�||d��}||vr*|||fSq|tjj}tjj|fS)a�Find the deepest match to *name* in the dictionary.

        The deepest match is the longest name in the dictionary which is
        a superdomain of *name*.  Note that *superdomain* includes matching
        *name* itself.

        *name*, a ``dns.name.Name``, the name to find.

        Returns a ``(key, value)`` where *key* is the deepest
        ``dns.name.Name``, and *value* is the value associated with *key*.
        rN)rr�rangerrr�empty)rr�depth�i�n�vrrr�get_deepest_matchXs
�zNameDict.get_deepest_match)�__name__�
__module__�__qualname__�__doc__�	__slots__rr!rr#r&r*r+r,r3�
__classcell__rrrrr$s		r)r7�collections.abcr�dns.namerrrrrr�<module>s