
    ,h                     2    d Z ddlmZ ddlZ G d de      Zy)zDNS name dictionary    )MutableMappingNc                   Z     e Zd ZdZg dZ fdZd Zd Zd Zd Z	d Z
d	 Zd
 Zd Z xZS )NameDictzA 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__storec                     t         |           t               | _        d| _        d| _        | j                  t        |i |       y )Nr   )super__init__dict_NameDict__storer   r   update)selfargskwargs	__class__s      N/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/dns/namedict.pyr   zNameDict.__init__-   s<    v D$)&)*    c                     t        |      | j                  k(  r| j                  dz   | _        y t        |      | j                  kD  rt        |      | _        d| _        y y )N   )lenr   r   r   keys     r   __update_max_depthzNameDict.__update_max_depth6   sM    s8t~~%#'#7#7!#;D X& XDN#$D  'r   c                      | j                   |   S Nr   r   s     r   __getitem__zNameDict.__getitem__=   s    ||C  r   c                     t        |t        j                  j                        st	        d      || j
                  |<   | j                  |       y )NzNameDict key must be a name)
isinstancednsnameName
ValueErrorr   _NameDict__update_max_depth)r   r   values      r   __setitem__zNameDict.__setitem__@   s<    #sxx}}-:;;!S$r   c                    | j                   j                  |       t        |      | j                  k(  r| j                  dz
  | _        | j                  dk(  r*d| _        | j                   D ]  }| j                  |        y y )Nr   r   )r   popr   r   r   r%   )r   r   ks      r   __delitem__zNameDict.__delitem__F   sr    s8t~~%#'#7#7!#;D 1$DN\\ +''*+ %r   c                 ,    t        | j                        S r   )iterr   r   s    r   __iter__zNameDict.__iter__O   s    DLL!!r   c                 ,    t        | j                        S r   )r   r   r.   s    r   __len__zNameDict.__len__R   s    4<<  r   c                     || j                   v S r   r   r   s     r   has_keyzNameDict.has_keyU   s    dll""r   c                 B   t        |      }|| j                  kD  r| j                  }t        | d      D ]1  }t        j                  j                  ||d       }|| v s*|| |   fc S  | t        j                  j                     }t        j                  j                  |fS )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*.
        r   N)r   r   ranger!   r"   r#   empty)r   r"   depthinvs         r   get_deepest_matchzNameDict.get_deepest_matchX   s     D	4>>!NNEvq! 	$Ad12h'ADy47|#	$  ""r   )__name__
__module____qualname____doc__	__slots__r   r%   r   r'   r+   r/   r1   r3   r;   __classcell__)r   s   @r   r   r   $   s<     <I+%!%+"!##r   r   )r?   collections.abcr   dns.namer!   r    r   r   <module>rE      s    8  + I#~ I#r   