f2dZddlmZddlZGddeZy)zDNS name dictionary)MutableMappingNcZeZdZdZgdZfdZdZdZdZdZ dZ d Z d Z d Z xZS) 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_depthmax_depth_items__storect|t|_d|_d|_|j t|i|y)Nr)super__init__dict_NameDict__storerrupdate)selfargskwargs __class__s U/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/dns/namedict.pyr zNameDict.__init__-s< v   D$)&)*ct||jk(r|jdz|_yt||jkDrt||_d|_yy)N)lenrrrkeys r__update_max_depthzNameDict.__update_max_depth6sM s8t~~ %#'#7#7!#;D X & XDN#$D 'rc |j|SNr rs r __getitem__zNameDict.__getitem__=s||C  rct|tjjs t d||j |<|j |y)NzNameDict key must be a name) isinstancednsnameName ValueErrorr _NameDict__update_max_depth)rrvalues r __setitem__zNameDict.__setitem__@s<#sxx}}-:; ;! S $rc|jj|t||jk(r|jdz |_|jdk(r*d|_|jD]}|j |yy)Nrr)r poprrrr%)rrks r __delitem__zNameDict.__delitem__Fsm  s8t~~ %#'#7#7!#;D   1 $DN\\''*" %rc,t|jSr)iterr rs r__iter__zNameDict.__iter__OsDLL!!rc,t|jSr)rr r.s r__len__zNameDict.__len__Rs4<<  rc||jvSrrrs rhas_keyzNameDict.has_keyUsdll""rcBt|}||jkDr |j}t| dD]1}tjj ||d}||vs*|||fcS|tjj }tjj |fS)aFind 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)rrranger!r"r#empty)rr"depthinvs rget_deepest_matchzNameDict.get_deepest_matchXsD  4>> !NNEvq!A d12h'ADy47|#"  ""r)__name__ __module__ __qualname____doc__ __slots__r r%rr'r+r/r1r3r; __classcell__)rs@rrr$s< rEs 8+I#~I#r