???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................3
¢báW]  ã               @   s6   d Z ddlZddlZddlmZ G dd„ dejƒZdS )zDNS name dictionaryé    Né   )Úxrangec               @   sb   e Zd ZdZdddgZdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )ÚNameDicta  A 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__storec             O   s(   t ƒ | _d| _d| _| jt ||Žƒ d S )Nr   )ÚdictÚ_NameDict__storer   r   Úupdate)ÚselfÚargsÚkwargs© r   ú/usr/lib/python3.6/namedict.pyÚ__init__-   s    zNameDict.__init__c             C   s>   t |ƒ| jkr| jd | _nt |ƒ| jkr:t |ƒ| _d| _d S )Nr   )Úlenr   r   )r
   Úkeyr   r   r   Z__update_max_depth3   s
    
zNameDict.__update_max_depthc             C   s
   | j | S )N)r   )r
   r   r   r   r   Ú__getitem__:   s    zNameDict.__getitem__c             C   s.   t |tjjƒstdƒ‚|| j|< | j|ƒ d S )NzNameDict key must be a name)Ú
isinstanceÚdnsÚnameÚNameÚ
ValueErrorr   Ú_NameDict__update_max_depth)r
   r   Úvaluer   r   r   Ú__setitem__=   s    
zNameDict.__setitem__c             C   sT   | j j|ƒ}t|ƒ| jkr&| jd | _| jdkrPd| _x| j D ]}| j|ƒ q>W d S )Nr   r   )r   Úpopr   r   r   r   )r
   r   r   Úkr   r   r   Ú__delitem__C   s    
zNameDict.__delitem__c             C   s
   t | jƒS )N)Úiterr   )r
   r   r   r   Ú__iter__L   s    zNameDict.__iter__c             C   s
   t | jƒS )N)r   r   )r
   r   r   r   Ú__len__O   s    zNameDict.__len__c             C   s
   || j kS )N)r   )r
   r   r   r   r   Úhas_keyR   s    zNameDict.has_keyc             C   sn   t |ƒ}|| jkr| j}x<t| dƒD ],}tjj||d… ƒ}|| kr&|| | fS q&W | tjj }tjj|fS )a  Find 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
        r   N)r   r   r   r   r   r   Úempty)r
   r   ÚdepthÚiÚnÚvr   r   r   Úget_deepest_matchU   s    
zNameDict.get_deepest_matchN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r   r   r   r   r    r!   r'   r   r   r   r   r   !   s   
	r   )r+   ÚcollectionsZdns.namer   Z_compatr   ÚMutableMappingr   r   r   r   r   Ú<module>   s   