flXddlZddlmZmZmZmZmZmZmZddl Z ddl Z ddl Z ddl Z ddlZ ddlZ ddlZ ddlZ ddlZ GddZGdde j(j*ZGdde j(j*ZGd d e j(j*Zd Zd Zed e j6j8e j:j<gdfZed e j6j8e j@jBe j@jBgdfZ"ed e j6j8gdfZ#Gdd Z$y)N)AnyCallableIteratorListOptionalTupleUnionceZdZd dZd deddfdZdeeejjeeejjffdZ dejjfdZdeejjfdZy ) TransactionManagerreturn Transactionct)zBegin a read-only transaction.NotImplementedErrorselfs X/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/dns/transaction.pyreaderzTransactionManager.reader!! replacementct)aBegin a writable transaction. *replacement*, a ``bool``. If `True`, the content of the transaction completely replaces any prior content. If False, the default, then the content of the transaction updates the existing content. r)rrs rwriterzTransactionManager.writers "!rct)aqReturns a tuple (absolute_origin, relativize, effective_origin) giving the absolute name of the default origin for any relative domain names, the "effective origin", and whether names should be relativized. The "effective origin" is the absolute origin if relativize is False, and the empty name if relativize is true. (The effective origin is provided even though it can be computed from the absolute_origin and relativize setting because it avoids a lot of code duplication.) If the returned names are `None`, then no origin information is available. This information is used by code working with transactions to allow it to coordinate relativization. The transaction code itself takes what it gets (i.e. does not change name relativity). rrs rorigin_informationz%TransactionManager.origin_information s 2"!rct)z%The class of the transaction manager.rrs r get_classzTransactionManager.get_class;rrc4|j\}}}|r|Sy)z#Origin to use in from_wire() calls.N)r)rabsolute_origin relativize_s rfrom_wire_originz#TransactionManager.from_wire_origin?s#+/+B+B+D(*a " "rN)r r )F)__name__ __module__ __qualname__rboolrrrdnsnameNamer rdataclass RdataClassrr"rrr r s|""$"="" x &hsxx}}.EE F"6"3>>44"(388=="9rr ceZdZdZy)DeleteNotExactz>Existing data did not match data specified by an exact delete.Nr#r$r%__doc__r,rrr.r.HsHrr.ceZdZdZy)ReadOnlyz*Tried to write to a read-only transaction.Nr/r,rrr2r2L4rr2ceZdZdZy) AlreadyEndedz*Tried to use an already-ended transaction.Nr/r,rrr5r5Pr3rr5c|$t|tjjr|Stjj|SN) isinstancer'rdatasetImmutableRdataset)r9s r_ensure_immutable_rdatasetr;Ts5:h 0N0NO << ) )( 33rch||jr|Stjj|Sr7) is_immutabler'node ImmutableNode)r>s r_ensure_immutable_noder@Zs, |t((* 88 ! !$ ''rr c eZdZ d9dededefdZejjfde e ejje fde ejje fde ejje fdejj fd Zdejjde ej$j&fd Zd:d Zd edd fdZd edd fdZd edd fdZd edd fdZde ejje fdefdZddejj8fdededejjdd fdZdZdefdZ d:dZ!d:dZ"de#dd fdZ$de%dd fdZ&de'dd fdZ(de)e*ejjejj ffd Z+de)ejjfd!Z,d"Z-d#Z.d$Z/d%Z0d&Z1d'Z2d(Z3d)Z4d*Z5d+Z6d,Z7d-Z8d.Z9d/Z:d0Z;d1Zd4Z?d5Z@d6ZAd7ZBd8ZCy );r managerr read_onlycf||_||_||_d|_g|_g|_g|_yNF)rBrrC_ended_check_put_rdataset_check_delete_rdataset_check_delete_name)rrBrrCs r__init__zTransaction.__init__ks9  &" ?A EG#=?rr(rdtypecoversr cb|jt|tr tjj |d}tj jj|}tj jj|}|j|||}t|S)zReturn the rdataset associated with *name*, *rdtype*, and *covers*, or `None` if not found. Note that the returned rdataset is immutable. N) _check_endedr8strr'r( from_text rdatatype RdataTypemake _get_rdatasetr;)rr(rKrLr9s rgetzTransaction.gets  dC 88%%dD1D((--f5((--f5%%dFF;)(33rc6t|j|S)z[Return the node at *name*, if any. Returns an immutable node or ``None``. )r@ _get_noderr(s rget_nodezTransaction.get_nodes &dnnT&:;;rNc(|jrtyr7)rCr2rs r_check_read_onlyzTransaction._check_read_onlys >>N rargsch|j|j|jd|y)zAdd records. The arguments may be: - rrset - name, rdataset... - name, ttl, rdata... FNrNr[_addrr\s raddzTransaction.adds*   %rch|j|j|jd|y)aReplace the existing rdataset at the name with the specified rdataset, or add the specified rdataset if there was no existing rdataset. The arguments may be: - rrset - name, rdataset... - name, ttl, rdata... Note that if you want to replace the entire node, you should do a delete of the name followed by one or more calls to add() or replace(). TNr^r`s rreplacezTransaction.replaces*"   $rch|j|j|jd|y)a Delete records. It is not an error if some of the records are not in the existing set. The arguments may be: - rrset - name - name, rdatatype, [covers] - name, rdataset... - name, rdata... FNrNr[_deleter`s rdeletezTransaction.deletes*$   UD!rch|j|j|jd|y)a4Delete records. The arguments may be: - rrset - name - name, rdatatype, [covers] - name, rdataset... - name, rdata... Raises dns.transaction.DeleteNotExact if some of the records are not in the existing set. TNrer`s r delete_exactzTransaction.delete_exacts*&   T4 rc|jt|tr tjj |d}|j |S)zDoes the specified name exist?N)rNr8rOr'r(rP _name_existsrXs r name_existszTransaction.name_existss?  dC 88%%dD1D  &&rTvaluerelativec|j|dkr tdt|tr tj j |d}|j|tjjtjj}|t|dk(rt|r0tjj|dj|z}ntjj|}|j}|dk(rd}|dj!|}tj"j%|j&|}|j!||y)aUpdate the serial number. *value*, an `int`, is an increment if *relative* is `True`, or the actual value to set if *relative* is `False`. Raises `KeyError` if there is no SOA rdataset at *name*. Raises `ValueError` if *value* is negative or if the increment is so large that it would cause the new serial to be less than the prior value. rznegative update_serial() valueNrm)serial)rN ValueErrorr8rOr'r(rPrTrQSOANONElenKeyErrorrqSerialrnrcr9 from_rdatattl)rrnror(r9rqrdata new_rdatasets r update_serialzTransaction.update_serials"  19=> > dC 88%%dD1D%%dCMM,=,=s}}?Q?QR  s8}1N ZZ&&x{'9'9:UBFZZ&&u-F Q;F ##6#2||..x||UC  T<(rcB|j|jSr7rN_iterate_rdatasetsrs r__iter__zTransaction.__iter__s &&((rcB|j|jS)aHas this transaction changed anything? For read-only transactions, the result is always `False`. For writable transactions, the result is `True` if at some time during the life of the transaction, the content was changed. )rN_changedrs rchangedzTransaction.changeds }}rc&|jdy)aCommit the transaction. Normally transactions are used as context managers and commit or rollback automatically, but it may be done explicitly if needed. A ``dns.transaction.Ended`` exception will be raised if you try to use a transaction after it has been committed or rolled back. Raises an exception if the commit fails (in which case the transaction is also rolled back. TN_endrs rcommitzTransaction.commit)s $rc&|jdy)avRollback the transaction. Normally transactions are used as context managers and commit or rollback automatically, but it may be done explicitly if needed. A ``dns.transaction.AlreadyEnded`` exception will be raised if you try to use a transaction after it has been committed or rolled back. Rollback cannot otherwise fail. FNrrs rrollbackzTransaction.rollback6s %rcheckc:|jj|y)aCall *check* before putting (storing) an rdataset. The function is called with the transaction, the name, and the rdataset. The check function may safely make non-mutating transaction method calls, but behavior is undefined if mutating transaction methods are called. The check function should raise an exception if it objects to the put, and otherwise should return ``None``. N)rGappendrrs rcheck_put_rdatasetzTransaction.check_put_rdatasetBs   ''.rc:|jj|y)aCall *check* before deleting an rdataset. The function is called with the transaction, the name, the rdatatype, and the covered rdatatype. The check function may safely make non-mutating transaction method calls, but behavior is undefined if mutating transaction methods are called. The check function should raise an exception if it objects to the put, and otherwise should return ``None``. N)rHrrs rcheck_delete_rdatasetz!Transaction.check_delete_rdatasetNs ##**51rc:|jj|y)aCall *check* before putting (storing) an rdataset. The function is called with the transaction and the name. The check function may safely make non-mutating transaction method calls, but behavior is undefined if mutating transaction methods are called. The check function should raise an exception if it objects to the put, and otherwise should return ``None``. N)rIrrs rcheck_delete_namezTransaction.check_delete_name[s &&u-rcB|j|jS)a@Iterate all the rdatasets in the transaction, returning (`dns.name.Name`, `dns.rdataset.Rdataset`) tuples. Note that as is usual with python iterators, adding or removing items while iterating will invalidate the iterator and may raise `RuntimeError` or fail to iterate over all entries.r~rs riterate_rdatasetszTransaction.iterate_rdatasetsgs &&((rcB|j|jS)zIterate all the names in the transaction. Note that as is usual with python iterators, adding or removing names while iterating will invalidate the iterator and may raise `RuntimeError` or fail to iterate over all entries.)rN_iterate_namesrs r iterate_nameszTransaction.iterate_namesss ""$$rc<t|dk7rtd|y)Nrzextra parameters to )ru TypeError)rmethodr\s r_raise_if_not_emptyzTransaction._raise_if_not_emptys% t9>26(;< < rc |j}t|tjjr|j }|St|tj jr|}|S|rd}n[t|tr-|}|tjjkDrt|dt|d|j}t|tjjr"tj j||}|St|d#t $r|rYyt|dwxYw)Nrz: TTL value too bigz: expected a TTLz: expected an Rdataz: expected more arguments)popleftr8r'rrsetRRset to_rdatasetr9RdatasetintryMAX_TTLrrrrzRdatarx IndexError)rrdeletingr\argr9rys r_rdataset_from_argszTransaction._rdataset_from_argss$ F,,.C#syy/??,$O#C!6!67 OC!#s+!0",x7J-K"LL'6(2B(CDD,,.Cc399??3"||66sC@HO$vh.A$BCC F 6(*C DEE  Fs%AD$'D$0B%D$D$$ E1Ec tj|}|rd}nd}|j}t|tr t j j|d}t|t j jr|}|j|d|}nQt|t jjr|}|j }|j}nt|d|j|jj!k7rt#|d|j$t j&j(k(r'|j+\}}} || k7rt#|d|j-|||s|j/||j$|j0} | t| t j2j4rRt j2j7| j| j$| j0} | j9| | } | j;|}|j=||y#t>$rtdwxYw)Nz replace()zadd()F/ requires a name or RRset as the first argument has objects of wrong RdataClassz has non-origin SOAnot enough parameters to ) collectionsdequerr8rOr'r(rPr)rrrrrrdclassrBrrrrKrQrs_origin_informationrrTrLr9r:rupdateunion_checked_put_rdatasetr) rrcr\rrr(r9rr!originexistingtrdss rr_zTransaction._adds) B$$T*D$ ,,.C#s#hh((d3#sxx}}-33FE4HC1zz!,,.hMN4<<#9#9#;; F8+K!LMM#--"3"33!%!9!9!;Av6>$x/B%CDD  $ $VT 2--dHOOX__U'!(CLL,J,JK"||44$,,hoox  H-#''~~h7H  & &tX 6 B7x@A A Bs IIIc tj|}|rd}nd}|j}t|tr t j j|d}t|t j jr.|}t|dkDr t|dtst|dtrt jjj|j}t|dkDr8t jjj|j}nt jj}|j|||j!|||}||rt#|dy|j%|||y|j'|d|} nAt|t j(j*r|} | j }nt-|d|j||| r| j.|j0j3k7rt5|d|j!|| j6| j8}||r$|j;| } | | k7rt#|d|j=| } t| dk(r(|j?|| j6| j8y|jA|| y|rAt#|d|r|jC|st#|d |jE|yy#tF$rt-d wxYw) Nzdelete_exact()zdelete()rz: missing rdatasetTrrz: missing rdatasz: name not knownr)$rrrr8rOr'r(rPr)rurrQrRrSrtrrTr._delete_rdatasetrrrrrrBrrrrKrL intersection difference_checked_delete_rdatasetrrk_checked_delete_namer) rexactr\rrr(rKrLrr9rs rrfzTransaction._deletes= B$$T*D)#,,.C#s#hh((d3#sxx}}-t9q=tAw, 47C0H!]]4499$,,.IF4y1}!$!8!8!=!=dlln!M!$!3!3,,VT:#11$GH' "0F8;M1N"OO--dFFC#77dKHC1}}hMN  $ $VT 2##t||'='='??$x/O%PQQ--dHOOX__U''/'<'s "!rct)zStore the rdataset.r)rr(r9s rrzTransaction._put_rdatasetDrrct)zhDelete all data associated with *name*. It is not an error if the name does not exist. rrXs rrzTransaction._delete_nameH "!rct)zDelete all data associated with *name*, *rdtype*, and *covers*. It is not an error if the rdataset does not exist. rrs rrzTransaction._delete_rdatasetOrrct)z2Does name exist? Returns a bool. rrXs rrkzTransaction._name_existsVrrct)z&Has this transaction changed anything?rrs rrzTransaction._changed]rrct)zEnd the transaction. *commit*, a bool. If ``True``, commit the transaction, otherwise roll it back. If committing and the commit fails, then roll back and raise an exception. rrs rrzTransaction._end_transactionas "!rct)zSet the origin. This method is called when reading a possibly relativized source, and an origin setting operation occurs (e.g. $ORIGIN in a zone file). r)rrs r _set_originzTransaction._set_originls "!rct)z7Return an iterator that yields (name, rdataset) tuples.rrs rrzTransaction._iterate_rdatasetsurrct)z&Return an iterator that yields a name.rrs rrzTransaction._iterate_namesyrrct)zPReturn the node at *name*, if any. Returns a node or ``None``. rrXs rrWzTransaction._get_node}rrc6|jjSr7)rBrrs rrzTransaction._origin_informations||..00r)FF)r N)Dr#r$r%r r&rJr'rQrtrr r(r)rOrRr9rrUr>NoderYr[rrarcrgrirlemptyrr|rrrrCheckPutRdatasetTyperCheckDeleteRdatasetTyperCheckDeleteNameTyperrrrrrrr_rfrNrrrrrrrTrrrrkrrrrrrWrr,rrr r js" @# @ @ @27:mm6H6H 4uSXX]]C/014cmm--s234cmm--s23 4    4& )%x 6%=F<*BX>B@+ 4  " """"" """""1r)%rtypingrrrrrrr dns.exceptionr'dns.namedns.nodedns.rdataclass dns.rdataset dns.rdatatype dns.rrset dns.serialdns.ttlr exception DNSExceptionr.r2r5r;r@r(r)r9rrrQrRrrr r,rrrsHHH44nIS]]//I5s}}))553==--54 (  CHHMM3<<#8#894?#CHHMM3==#:#:CMM