Your IP : 3.21.247.221


Current Path : /usr/lib/python3.6/site-packages/dns/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/dns/__pycache__/namedict.cpython-36.opt-1.pyc

3

�b�W]�@s6dZddlZddlZddlmZGdd�dej�ZdS)zDNS name dictionary�N�)�xrangec@sbeZdZdZdddgZdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�NameDictaA dictionary whose keys are dns.name.Name objects.
    @ivar max_depth: the maximum depth of the keys that have ever been
    added to the dictionary.
    @type max_depth: int
    @ivar max_depth_items: the number of items of maximum depth
    @type max_depth_items: int
    �	max_depth�max_depth_itemsZ__storecOs(t�|_d|_d|_|jt||��dS)Nr)�dict�_NameDict__storerr�update)�self�args�kwargs�r
�/usr/lib/python3.6/namedict.py�__init__-szNameDict.__init__cCs>t|�|jkr|jd|_nt|�|jkr:t|�|_d|_dS)Nr)�lenrr)r
�keyr
r
rZ__update_max_depth3s

zNameDict.__update_max_depthcCs
|j|S)N)r)r
rr
r
r�__getitem__:szNameDict.__getitem__cCs.t|tjj�std��||j|<|j|�dS)NzNameDict key must be a name)�
isinstance�dns�name�Name�
ValueErrorr�_NameDict__update_max_depth)r
r�valuer
r
r�__setitem__=s
zNameDict.__setitem__cCsT|jj|�}t|�|jkr&|jd|_|jdkrPd|_x|jD]}|j|�q>WdS)Nrr)r�poprrrr)r
rr�kr
r
r�__delitem__Cs
zNameDict.__delitem__cCs
t|j�S)N)�iterr)r
r
r
r�__iter__LszNameDict.__iter__cCs
t|j�S)N)rr)r
r
r
r�__len__OszNameDict.__len__cCs
||jkS)N)r)r
rr
r
r�has_keyRszNameDict.has_keycCsnt|�}||jkr|j}x<t|d�D],}tjj||d��}||kr&|||fSq&W|tjj}tjj|fS)aFind the deepest match to I{name} in the dictionary.

        The deepest match is the longest name in the dictionary which is
        a superdomain of I{name}.

        @param name: the name
        @type name: dns.name.Name object
        @rtype: (key, value) tuple
        rN)rrrrrr�empty)r
r�depth�i�n�vr
r
r�get_deepest_matchUs
zNameDict.get_deepest_matchN)�__name__�
__module__�__qualname__�__doc__�	__slots__rrrrrrr r!r'r
r
r
rr!s
	r)r+�collectionsZdns.namerZ_compatr�MutableMappingrr
r
r
r�<module>s

?>