
    hA.                        S r SSKrSSK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\	R"                  R$                  5      r\	R(                  R*                  r\	R(                  R.                  r\	R(                  R2                  r\	R(                  R4                  r\	R(                  R6                  r\	R(                  R8                  r " S S\	R(                  R:                  5      rg)zDNS Versioned Zones.    N)CallableDequeSetcastc                       \ rS rSrSrSrg)UseTransaction   z-To alter a versioned zone, use a transaction. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r
       bC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\dns/versioned.pyr   r      s    7r   r   c                     ^  \ rS rSr% / SQr\r\/ \R                  R
                  4   \
S'   \R                  R                  SS4S\R                  R                  \-  S-  S\R                  R                   S\S	\S \/\S-  4   S-  4U 4S
 jjjr S*S\S-  S\S-  S\4S jjrS+S\S\4S jjrS rS rS rS\S-  SS4S jrS\S \/\S-  4   S-  SS4S jrS rS rS rS r S r!S r" S+S\R                  R                  \-  S \S\R                  R
                  4U 4S! jjjr#S\R                  R                  \-  SS4S" jr$\RJ                  RL                  S4S\R                  R                  \-  S#\RJ                  RN                  \-  S$\RJ                  RN                  \-  S \S\RP                  RR                  4
U 4S% jjjr*\RJ                  RL                  S4S\R                  R                  \-  S#\RJ                  RN                  \-  S$\RJ                  RN                  \-  S \S\RP                  RR                  S-  4
U 4S& jjjr+\RJ                  RL                  4S\R                  R                  \-  S#\RJ                  RN                  \-  S$\RJ                  RN                  \-  SS4S' jjr,S\R                  R                  \-  S\RP                  RR                  SS4S( jr-S)r.U =r/$ ),Zone    )	_versions_versions_lock
_write_txn_write_waiters_write_event_pruning_policy_readersnode_factoryTNoriginrdclass
relativizepruning_policyc                 h  > [         TU ]  XU5        [        R                  " 5       U l        [
        R                  " 5       U l        Uc  U R                  U l	        OX@l	        SU l
        SU l        [        R                  " 5       U l        [        5       U l        U R                  S[!        U SS9U5        g)ar  Initialize a versioned zone object.

*origin* is the origin of the zone.  It may be a ``dns.name.Name``,
a ``str``, or ``None``.  If ``None``, then the zone's origin will
be set by the first ``$ORIGIN`` line in a zone file.

*rdclass*, an ``int``, the zone's rdata class; the default is class IN.

*relativize*, a ``bool``, determine's whether domain names are
relativized to the zone's origin.  The default is ``True``.

*pruning policy*, a function taking a ``Zone`` and a ``Version`` and returning
a ``bool``, or ``None``.  Should the version be pruned?  If ``None``,
the default policy, which retains one version is used.
NT)replacement)super__init__collectionsdequer   	threadingLock_version_lock_default_pruning_policyr   r   r   r   setr   _commit_version_unlockedWritableVersion)selfr   r   r    r!   	__class__s        r   r%   Zone.__init__-   s    , 	*5)4):):)<&^^-!#'#?#?D #1 .2486A6G6G6I*-%%%/$D96	
r   idserialreturnc                    Ub  Ub  [        S5      eU R                     UbB  S n[        U R                  5       H  nUR                  U:X  d  M  Un  O   Uc  [        S5      eGO<UGb)  U R                  (       a  [        R                  R                  nOU R                  c   eU R                  nS n[        U R                  5       H  nUR                  R                  U5      nU(       d  M'  UR                  U R                  [        R                  R                   5      nUc  M`  [#        [        R$                  R&                  R                   R                   US   5      nU(       d  M  UR(                  U:X  d  M  Un  O   Uc  [        S5      eOU R                  S   n[+        U SU5      n	U R,                  R/                  U	5        U	sS S S 5        $ ! , (       d  f       g = f)Nz!cannot specify both id and serialzversion not foundr   zserial not foundF)
ValueErrorr*   reversedr   r2   KeyErrorr    dnsnameemptyr   nodesgetget_rdatasetr   	rdatatypeSOAr   rdtypesANYr3   Transactionr   add)
r/   r2   r3   versionvonamenrdssoatxns
             r   readerZone.readerR   s    >f0@AA~!$..1Attrz"# 2 ?"#677 ##??HHNNE;;222 KKE!$..1AE*AqnnT\\3==;L;LM;$"3;;??#6#6#:#:CFC33::#7&'G! 2 ?"#566 # ..,dE73CMMc"A  s&   ,GBG-A9G*G<AG
G!Fr#   c                    S n U R                      U R                  c/  X R                  :X  a   [        XSS9U l        S U l         S S S 5        OJ[        R
                  " 5       nU R                  R                  U5        S S S 5        UR                  5         M  U R                  R                  5         U R                  $ ! , (       d  f       NF= f)NT)make_immutable)
r*   r   r   rD   r(   Eventr   appendwait_setup_version)r/   r#   events      r   writerZone.writery   s    ##
 ??*u8I8I/I '2$'DO )-D%! $#( ")##**51+ $R JJLU X 	&&(Y $#s   4B=0B==
Cc                     [        U R                  5      S:  a:  U R                  R                  5       U l        U R                  R	                  5         g g )Nr   )lenr   popleftr   r,   )r/   s    r   !_maybe_wakeup_one_waiter_unlocked&Zone._maybe_wakeup_one_waiter_unlocked   sC    t""#a' $ 3 3 ; ; =D!!# (r   c                     g)NTr
   )r/   zonerF   s      r   r+   Zone._default_pruning_policy   s    r   c                    [        U R                  5      S:  d   e[        U R                  5      S:  a  [        S U R                   5       5      nOU R                  S   R                  nU R                  S   R                  U:  a  U R                  X R                  S   5      (       a^  U R                  R                  5         U R                  S   R                  U:  a&  U R                  X R                  S   5      (       a  M\  g g g g )Nr   c              3   L   #    U  H  oR                   R                  v   M     g 7fN)rF   r2   ).0rL   s     r   	<genexpr>0Zone._prune_versions_unlocked.<locals>.<genexpr>   s     E}[[^^}s   "$r6   )rY   r   r   minr2   r   rZ   )r/   
least_kepts     r   _prune_versions_unlockedZone._prune_versions_unlocked   s    4>>"Q&&& t}}!Et}}EEJ+..JnnQ""Z/D4H4H..#5
 5
 NN""$ nnQ""Z/D4H4H..#5
 5
/ 5
/r   max_versionsc                 j   ^ Tb  TS:  a  [        S5      eTc  S nOU4S jnU R                  U5        g)zISet a pruning policy that retains up to the specified number
of versions
N   zmax versions must be at least 1c                     g)NFr
   )r^   _s     r   policy%Zone.set_max_versions.<locals>.policy   s    r   c                 4   > [        U R                  5      T:  $ rb   )rY   r   )r^   rn   rj   s     r   ro   rp      s    4>>*\99r   )r7   set_pruning_policy)r/   rj   ro   s    ` r   set_max_versionsZone.set_max_versions   s>     #q(8>??
: 	'r   ro   c                     Uc  U R                   nU R                     Xl        U R                  5         SSS5        g! , (       d  f       g= f)a  Set the pruning policy for the zone.

The *policy* function takes a `Version` and returns `True` if
the version should be pruned, and `False` otherwise.  `None`
may also be specified for policy, in which case the default policy
is used.

Pruning checking proceeds from the least version and the first
time the function returns `False`, the checking stops.  I.e. the
retained versions are always a consecutive sequence.
N)r+   r*   r   rh   )r/   ro   s     r   rr   Zone.set_pruning_policy   s;     >11F#) ))+  s	   <
A
c                     U R                      U R                  R                  U5        U R                  5         S S S 5        g ! , (       d  f       g = frb   )r*   r   removerh   r/   rL   s     r   	_end_readZone._end_read   s5    MM  %))+  s   ,A
Ac                 V    U R                   U:X  d   eS U l         U R                  5         g rb   )r   r[   ry   s     r   _end_write_unlockedZone._end_write_unlocked   s'    #%%%..0r   c                 r    U R                      U R                  U5        S S S 5        g ! , (       d  f       g = frb   )r*   r}   ry   s     r   
_end_writeZone._end_write   s%    $$S)  s   (
6c                     U R                   R                  U5        U R                  5         UR                  U l        U R                  c  X0l        Ub  U R                  U5        g g rb   )r   rR   rh   r=   r   r}   r/   rL   rF   r   s       r   r-   Zone._commit_version_unlocked   sR    g&%%']]
;; K?$$S) r   c                 t    U R                      U R                  XU5        S S S 5        g ! , (       d  f       g = frb   )r*   r-   r   s       r   _commit_versionZone._commit_version  s'    ))#?  s   )
7c                 x    [        U R                  5      S:  a  U R                  S   R                  S-   nU$ SnU$ )Nr   r6   rl   )rY   r   r2   )r/   r2   s     r   _get_next_version_idZone._get_next_version_id	  s?    t~~"#&&*B 	 B	r   r;   createc                 <   > U(       a  [         e[        TU ]	  U5      $ rb   )r   r$   	find_node)r/   r;   r   r0   s      r   r   Zone.find_node  s       w &&r   c                     [         erb   r   )r/   r;   s     r   delete_nodeZone.delete_node  s    r   rdtypecoversc                 |   > U(       a  [         e[        TU ]	  XU5      n[        R                  R                  U5      $ rb   )r   r$   find_rdatasetr:   rdatasetImmutableRdatasetr/   r;   r   r   r   r   r0   s         r   r   Zone.find_rdataset  s4       7(v>||--h77r   c                    > U(       a  [         e[        TU ]	  XU5      nUb  [        R                  R                  U5      $ g rb   )r   r$   r?   r:   r   r   r   s         r   r?   Zone.get_rdataset&  s=       7'f=<<11(;;r   c                     [         erb   r   )r/   r;   r   r   s       r   delete_rdatasetZone.delete_rdataset5  s
     r   c                     [         erb   r   )r/   r;   r#   s      r   replace_rdatasetZone.replace_rdataset=  s
     r   )	r   r   r*   r   r   r   r   r=   r   )NN)F)0r   r   r   r   	__slots__Noder   r   r:   node__annotations__
rdataclassINr;   Namestr
RdataClassboolVersionr%   intrD   rM   rV   r[   r+   rh   rs   rr   rz   r}   r   r-   r   r   r   r   r@   NONE	RdataTyper   Rdatasetr   r?   r   r   r   __classcell__)r0   s   @r   r   r       sT   I 15L(2sxx}},-4
 .1^^->->JN#
#d*#
 **#
 	#

 !&'!2D4K!?@4G#
 #
L ;?%*%-04Z%	%N/$ /; /b$
%$(S4Z (D ($,0$+=>E,	,(,
1
**@ 9>'HHMMC''15'	' ' 3   140B0B
8hhmmc!
8 ''#-
8 ''#-	
8
 
8 
		
8 
8  140B0Bhhmmc! ''#- ''#-	
  
			% & 140B0B	hhmmc! ''#- ''#-	
 
HHMMC'69ll6K6K	 r   r   )r   r&   r(   typingr   r   r   r   dns.exceptionr:   dns.namedns.nodedns.rdataclassdns.rdatasetdns.rdatatypedns.rdtypes.ANY.SOAdns.zone	exceptionDNSExceptionr   r^   VersionedNoder   ImmutableVersionedNodeImmutableNoder   r.   ImmutableVersionrD   r   r
   r   r   <module>r      s       - -        8S]]// 8
 xx//
((

((**88,, hh""`388== `r   