
    h3                        S SK r S SKJr  S SKJrJrJrJr  S SKr	S SK
r	S SKr	S SKr	S SKr	S SKr	S SKr	S SKr	S SKr	 " S S\ R$                  5      r " S S\	R(                  R*                  5      r\	R,                  R,                   " S S	\5      5       r " S
 S\	R0                  R2                  \	R4                  R6                     5      r " S S\	R:                  R<                  5      r\" SS9 " S S5      5       r\	R,                  R,                   " S S\	R:                  R@                  5      5       r! " S S\	RD                  RF                  5      r#g)    N)	dataclass)CallableMutableMappingTuplecastc                        \ rS rSrSrSrSrSrg)	NodeFlags             N)__name__
__module____qualname____firstlineno__ORIGIN
DELEGATIONGLUE__static_attributes__r       bC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\dns/btreezone.pyr	   r	      s    FJDr   r	   c                   Z   ^  \ rS rSrSS/rSS\S-  4U 4S jjjrS rS rS r	S	 r
S
rU =r$ )Node#   flagsidNc                 X   > [         TU ]  5         Uc  [        S5      nXl        SU l        g Nr   )super__init__r	   r   r   )selfr   	__class__s     r   r!   Node.__init__&   s*    = aLE
r   c                 B    U R                   [        R                  -  S:g  $ r   )r   r	   r   r"   s    r   is_delegationNode.is_delegation0   s    

Y111a77r   c                 B    U R                   [        R                  -  S:g  $ r   )r   r	   r   r&   s    r   is_glueNode.is_glue3   s    

Y^^+11r   c                 B    U R                   [        R                  -  S:g  $ r   )r   r	   r   r&   s    r   	is_originNode.is_origin6   s    

Y---!33r   c                 d    U R                   [        R                  [        R                  -  -  S:g  $ r   )r   r	   r   r   r&   s    r   is_origin_or_glueNode.is_origin_or_glue9   s%    

i..?@QFFr   )r   r   N)r   r   r   r   	__slots__r	   r!   r'   r*   r-   r0   r   __classcell__r#   s   @r   r   r   #   s=    $Ii$.  824G Gr   r   c                   &  ^  \ rS rSrS\4U 4S jjr\R                  R                  S4S\R                  R                  S\R                  R                  S\R                  R                  S\S	\R                  R                  4
U 4S
 jjjr\R                  R                  S4S\R                  R                  S\R                  R                  S\R                  R                  S\S	\R                  R                  S-  4
U 4S jjjr\R                  R                  4S\R                  R                  S\R                  R                  S\R                  R                  S	S4S jjrS\R                  R                  S	S4S jrS	\4S jrSrU =r$ )ImmutableNode=   nodec                    > [         TU ]  5         UR                  U l        [        UR                   Vs/ s H"  n[
        R                  R                  U5      PM$     sn5      U l        UR                  U l        g s  snf r2   )	r    r!   r   tuple	rdatasetsdnsrdatasetImmutableRdatasetr   )r"   r9   rdsr#   s      r   r!   ImmutableNode.__init__?   s]    ''<@NNKNSS\\++C0NK
 ZZ
 Ls   )A;Frdclassrdtypecoverscreatereturnc                 J   > U(       a  [        S5      e[        TU ]	  XUS5      $ N	immutableF)	TypeErrorr    find_rdatasetr"   rB   rC   rD   rE   r#   s        r   rK   ImmutableNode.find_rdatasetG   s'     K((w$WfeDDr   Nc                 J   > U(       a  [        S5      e[        TU ]	  XUS5      $ rH   )rJ   r    get_rdatasetrL   s        r   rO   ImmutableNode.get_rdatasetR   s'     K((w#GVUCCr   c                     [        S5      eNrI   rJ   )r"   rB   rC   rD   s       r   delete_rdatasetImmutableNode.delete_rdataset]   s     $$r   replacementc                     [        S5      erR   rS   )r"   rV   s     r   replace_rdatasetImmutableNode.replace_rdatasete   s    $$r   c                     gNTr   r&   s    r   is_immutableImmutableNode.is_immutableh   s    r   )r   r   r<   )r   r   r   r   r   r!   r=   	rdatatypeNONE
rdataclass
RdataClass	RdataTypeboolr>   RdatasetrK   rO   rT   rX   r\   r   r4   r5   s   @r   r7   r7   =   s    T   +.--*<*<	E**	E ''	E ''		E
 	E 
			E 	E +.--*<*<	D**	D ''	D ''		D
 	D 
			%	D 	D +.--*<*<	%**% ''% ''	%
 
%%CLL,A,A %d %d  r   r7   c                       \ rS rSrS\R
                  R                  S\\R
                  R                  S-  \4   4S jr	S\R
                  R                  S\4S jr
Srg)Delegationsl   namerF   Nc                 h   U R                  5       nUR                  USS9  UR                  5       nUc  gUR                  5       nUR	                  U5      u  n  nU[
        R                  R                  R                  :H  nU(       d(  U[
        R                  R                  R                  :X  a  XG4$ g)a  Get the delegation applicable to *name*, if it exists.

If there delegation, then return a tuple consisting of the name of
the delegation point, and a boolean which is `True` if the name is a proper
subdomain of the delegation point, and `False` if it is equal to the delegation
point.
FbeforeNF)
cursorseekprevkeyfullcomparer=   rh   NameRelation	SUBDOMAINEQUAL)r"   rh   rm   ro   cutreln_is_subdomains           r   get_delegationDelegations.get_delegationm   s     D'{{}<hhj%%c*
asxx44>>>4388#8#8#>#>>$$r   c                 t    U R                  5       nUR                  USS9  U R                  U5      u  p4Uc  gU$ )z0Is *name* glue, i.e. is it beneath a delegation?Frj   )rm   rn   ry   )r"   rh   rm   ru   rx   s        r   r*   Delegations.is_glue   s>    D' //5;r   r   )r   r   r   r   r=   rh   Namer   rc   ry   r*   r   r   r   r   rf   rf   l   sP    388== U388==4;OQU;U5V *CHHMM d r   rf   c                     ^  \ rS rSrSS\R
                  R                  S\4U 4S jjjrS\R                  R                  S\4S jrS\R                  R                  S\\R                  R                  \R                  R                  4   4U 4S jjrS\R                  R                  S	\SS
4S jrS\R                  R                  SS
4S jrS\R                  R                  S\R$                  R&                  SS
4S jrS\R                  R                  S\R*                  R,                  S\R*                  R,                  SS
4S jrSrU =r$ )WritableVersion   zonerV   c                 P  > [         TU ]  US5        U(       d  [        U[        R                  R
                  5      (       d   eUR                  S   n[        R                  R                  UR                  S9U l	        [        UR                  S9U l        g [        5       U l        g )NT)original)r    r!   
isinstancer=   	versionedZone	_versionsbtree	BTreeDictnodesrf   delegations)r"   r   rV   versionr#   s       r   r!   WritableVersion.__init__   s    t$dCMM$6$67777nnR(GCF99CVCV  DW DDJ  +G4G4GHD*}Dr   rh   rF   c                     U R                   R                  (       a  U[        R                  R                  :H  $ XR                   R
                  :H  $ r2   )r   
relativizer=   rh   emptyorigin)r"   rh   s     r   
_is_originWritableVersion._is_origin   s7     99388>>))99++++r   c                 J  > [         TU ]  U5      u  p![        [        U5      nU R	                  U5      (       a&  U=R
                  [        R                  -  sl        X!4$ U R                  R                  U5      (       a#  U=R
                  [        R                  -  sl        X!4$ r2   )r    _maybe_cow_with_namer   r   r   r   r	   r   r   r*   r   )r"   rh   r9   r#   s      r   r   $WritableVersion._maybe_cow_with_name   s     w3D9D$??4  JJ)***J | %%d++JJ)..(J|r   r*   Nc                 `   U R                   R                  5       nUR                  US5        / n UR                  5       nUc  GOQUR	                  5       nUR                  U5      (       d  GO)[        [        R                  R                  UR                  5       5      nX`R                  ;  am  U R                  R                  5       nU R                  Ul        UR                  R!                  UR                  5        U R                  R#                  U5        Un[%        U[        5      (       d   eU(       a$  U=R&                  [(        R*                  -  sl        O$U=R&                  [(        R*                  ) -  sl        UR-                  Xg45        GMf  U H  u  pgXpR                   U'   M     g rl   )r   rm   rn   nextrp   rx   r   r=   r9   r   valuechangedr   node_factoryr   r<   extendaddr   r   r	   r   append)	r"   rh   r*   rm   updateseltenamer9   new_nodes	            r   update_glue_flag WritableVersion.update_glue_flag   s7   ""$D% ++-C{GGIE%%d++syy{3DLL(99113"gg""))$..9  'dD))))

inn,


y~~o-

 NNE=)/ 0 #KE $JJu #r   c                 8   U R                  U5      nU R                  R                  U5      nUbk  UR                  5       (       a-  U R                  R                  U5        U R                  US5        U R                  U	 U R                  R                  U5        g g rl   )	_validate_namer   getr'   r   discardr   r   r   )r"   rh   r9   s      r   delete_nodeWritableVersion.delete_node   s    ""4(zz~~d#!!##  ((.%%dE2

4 LLT" r   r>   c                    U R                  U5      u  p1UR                  [        R                  R                  :X  at  UR                  5       (       d_  U=R                  [        R                  -  sl        XR                  ;  a-  U R                  R                  U5        U R                  US5        UR                  U5        g r[   )r   rC   r=   r^   NSr0   r   r	   r   r   r   r   rX   )r"   rh   r>   r9   s       r   put_rdatasetWritableVersion.put_rdataset   s     006OOs}}///8N8N8P8PJJ)...J+++  $$T*%%dD1h'r   rC   rD   c                    U R                  U5      u  pAU[        R                  R                  :X  a`  XR                  ;   aQ  U=R
                  [        R                  ) -  sl        U R                  R                  U5        U R                  US5        UR                  U R                  R                  X#5        [        U5      S:X  a  U R                  U	 g g )NFr   )r   r=   r^   r   r   r   r	   r   r   r   rT   r   rB   lenr   )r"   rh   rC   rD   r9   s        r   rT   WritableVersion.delete_rdataset   s     006S]]%%%$2B2B*BJJ9////J$$T*!!$.TYY..?t9>

4  r   )r   r   )F)r   r   r   r   r=   r   r   rc   r!   rh   r}   r   r   r9   r   r   r   r   r>   rd   r   r^   rb   rT   r   r4   r5   s   @r   r   r      s-   
-SXX]] 
- 
- 
-,sxx}} , ,	HHMM		sxx}}chhmm+	,	%SXX]] %T %d %># #$ #(HHMM(-0\\-B-B(	(!hhmm! ''! ''	!
 
! !r   r   T)frozenc                       \ rS rSr% \R
                  R                  \S'   \R
                  R                  \S'   \R
                  R                  S-  \S'   \R
                  R                  \S'   \\S'   \\S'   S	 r	S
r
g)Bounds   rh   leftNrightclosest_encloseris_equalr'   c           
          U R                   (       a  SnOSnU R                  (       a  SnOSnU R                   SU SU R                   SU R                   U SU R
                   3
$ )N=<z zonecut  z < z; )r   r'   r   rh   r   r   )r"   opzonecuts      r   __str__Bounds.__str__   se    ==BB GGyyk2$a		{#djj\'"$$%'	
r   r   )r   r   r   r   r=   rh   r}   __annotations__rc   r   r   r   r   r   r   r      sO    
((--
((--88==4hhmm#N
r   r   c                      ^  \ rS rSrS\R
                  R                  4U 4S jjrS\R                  R                  \
-  S\4S jrSrU =r$ )ImmutableVersioni
  r   c                   > [        U[        5      (       d  [        S5      e[        TU ]  UR
                  S5        UR                  U l        UR                  U l        UR                   H?  nUR                  R                  U5      nU(       d  M'  [        U5      UR                  U'   MA     [        [        [        R                  R                   [        R"                  R$                  4   UR                  5      U l	        U R                  R'                  5         UR(                  U l        U R(                  R'                  5         g )NzIa dns.btreezone.ImmutableVersion requires a dns.btreezone.WritableVersionT)r   r   
ValueErrorr    r!   r   r   r   r   r   r   r7   r   r   r=   rh   r}   r9   r   make_immutabler   )r"   r   rh   r9   r#   s       r   r!   ImmutableVersion.__init__  s    '?330  	t,**nnOOD==$$T*Dt&3D&9d# $
 .)EFV


!!#"..'')r   rh   rF   c                    U R                   c   eU R                  R                  U R                   5      nU R                  R                  U5      nU R                  R	                  U5      u  p4Ub  UnSnOUnSn[        [        R                  R                  U R                  5      R                  5       nUR                  US5        UR                  5       nUc   eUR                  5          UR                  5       n	U	b#  U	R                  5       R                  5       (       d  OM9  UR!                  5       R#                  U5      n
U	b"  U	R!                  5       nUR#                  U5      nO([        R$                  R&                  S[)        U5      4nSn[        R$                  R+                  U[-        U
S   US   5      * S 5      n[/        UUR!                  5       UUU
S   [        R$                  R0                  R2                  :H  U5      $ )a  Return the 'bounds' of *name* in its zone.

The bounds information is useful when making an authoritative response, as
it can be used to determine whether the query name is at or beneath a delegation
point.  The other data in the ``Bounds`` object is useful for making on-the-fly
DNSSEC signatures.

The left bound of *name* is *name* itself if it is in the zone, or the greatest
predecessor which is in the zone.

The right bound of *name* is the least successor of *name*, or ``None`` if
no name in the zone is greater than *name*.

The closest encloser of *name* is *name* itself, if *name* is in the zone;
otherwise it is the name with the largest number of labels in common with
*name* that is in the zone, either explicitly or by the implied existence
of empty non-terminals.

The bounds *is_equal* field is ``True`` if and only if *name* is equal to
its left bound.

The bounds *is_delegation* field is ``True`` if and only if the left bound is a
delegation point.
NTFr   r   r   )r   r   r   r   ry   r   r=   r   r   r   rm   rn   ro   r   r   r*   rp   rq   rh   NAMERELN_COMMONANCESTORr   r}   maxr   rr   rt   )r"   rh   r   ru   rw   targetr'   cr   r   left_comparison	right_keyright_comparisonr   s                 r   boundsImmutableVersion.bounds  s   2 {{&&&))$++6yy''-!!006?F MF!M$$djj188:	vuvvx	FFHE}EKKM$9$9$;$;  ((*006		I(44T: 00F 
 I88==#oa(*:1*=>>@A
 HHJA#(("7"7"="==
 	
r   )r   r   r   r   )r   r   r   r   r=   r   Versionr!   rh   r}   strr   r   r   r4   r5   s   @r   r   r   
  sB    * 0 0 *&B
388==3. B
6 B
 B
r   r   c                   v   \ rS rSr% \r\/ \R                  R                  4   \	S'   \
" \/ \\R                  R                  \R                  R                  4   4   \R                  R                  \R                  R                  \4   5      r\/ \\R                  R                  \R                  R                  4   4   \	S'   \r\\R&                  R(                  \/\R&                  R,                  4   S-  \	S'   \r\\R&                  R,                  /\R&                  R,                  4   S-  \	S'   Srg)r   id  r   map_factoryNwritable_version_factoryimmutable_version_factoryr   )r   r   r   r   r   r   r   r=   r9   r   r   r   rh   r}   r   r   r   r   r   r   r   rc   r   r   r   r   r   r   r   r   r   d  s
   04L(2sxx}},-4NR^CHHMM388==$@AAB		CHHMM4/0OK"nSXX]]CHHMM-IJJK  	 #((--&(8(889D@ 	 x)9)9(:CHH<L<L(LMPTT r   r   )$enumdataclassesr   typingr   r   r   r   	dns.btreer=   dns.immutabledns.namedns.nodedns.rdataclassdns.rdatasetdns.rdatatypedns.versioneddns.zoneIntFlagr	   r9   r   rI   r7   r   BTreeSetrh   r}   rf   r   r   r   r   r   r   r   r   r   r   <module>r      s    ! 8 8          G388== G4 +D + +\#))$$SXX]]3 @c!chh.. c!L $
 
 
. V
sxx'' V
 V
r3== r   