
                         B    S r SSKJr  SSKrSSKrSSKr " S S\5      rg)z)DNS nodes.  A node is a set of rdatasets.    )StringIONc                       \ rS rSrSrS/rS rS rS rS r	S r
S	 rS
 r\R                  R                  S4S jr\R                  R                  S4S jr\R                  R                  4S jrS rSrg)Node   zA Node is a set of rdatasets.	rdatasetsc                     / U l         g Nr   selfs    lib/third_party/dns/node.py__init__Node.__init__!   s	        c                     [        5       nU R                   HG  n[        U5      S:  d  M  UR                  UR                  " U40 UD65        UR                  S5        MI     UR                  5       SS $ )zConvert a node to text format.

Each rdataset at the node is printed.  Any keyword arguments
to this method are passed on to the rdataset's to_text() method.

*name*, a ``dns.name.Name`` or ``text``, the owner name of the rdatasets.

Returns a ``text``.
r   
N)r   r   lenwriteto_textgetvalue)r   namekwsrdss        r   r   Node.to_text%   s^     J>>C3x!|D/B/0 " zz|CR  r   c                 6    S[        [        U 5      5      -   S-   $ )Nz
<DNS node >)stridr   s    r   __repr__Node.__repr__7   s    c"T(m+c11r   c                     U R                    H  nX!R                   ;  d  M    g   UR                    H  nX R                   ;  d  M    g   g)NFTr
   )r   otherrds      r   __eq__Node.__eq__:   sA     ..B( ! //B' " r   c                 .    U R                  U5      (       + $ r	   )r&   )r   r$   s     r   __ne__Node.__ne__F   s    ;;u%%%r   c                 ,    [        U R                  5      $ r	   )r   r   r   s    r   __len__Node.__len__I   s    4>>""r   c                 ,    [        U R                  5      $ r	   )iterr   r   s    r   __iter__Node.__iter__L   s    DNN##r   Fc                     U R                    H  nUR                  XU5      (       d  M  Us  $    U(       d  [        e[        R                  R                  X5      nU R                   R                  U5        U$ )a]  Find an rdataset matching the specified properties in the
current node.

*rdclass*, an ``int``, the class of the rdataset.

*rdtype*, an ``int``, the type of the rdataset.

*covers*, an ``int``, the covered type.  Usually this value is
dns.rdatatype.NONE, but if the rdtype is dns.rdatatype.SIG or
dns.rdatatype.RRSIG, then the covers value will be the rdata
type the SIG/RRSIG covers.  The library treats the SIG and RRSIG
types as if they were a family of
types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).  This makes RRSIGs much
easier to work with than if RRSIGs covering different rdata
types were aggregated into a single RRSIG rdataset.

*create*, a ``bool``.  If True, create the rdataset if it is not found.

Raises ``KeyError`` if an rdataset of the desired type and class does
not exist and *create* is not ``True``.

Returns a ``dns.rdataset.Rdataset``.
)r   matchKeyErrordnsrdatasetRdatasetappendr   rdclassrdtypecoverscreater   s         r   find_rdatasetNode.find_rdatasetO   s]    4 >>Cyy&11
 " Nll##G4c"
r   c                 R     U R                  XX45      nU$ ! [         a    Sn U$ f = f)ag  Get an rdataset matching the specified properties in the
current node.

None is returned if an rdataset of the specified type and
class does not exist and *create* is not ``True``.

*rdclass*, an ``int``, the class of the rdataset.

*rdtype*, an ``int``, the type of the rdataset.

*covers*, an ``int``, the covered type.  Usually this value is
dns.rdatatype.NONE, but if the rdtype is dns.rdatatype.SIG or
dns.rdatatype.RRSIG, then the covers value will be the rdata
type the SIG/RRSIG covers.  The library treats the SIG and RRSIG
types as if they were a family of
types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).  This makes RRSIGs much
easier to work with than if RRSIGs covering different rdata
types were aggregated into a single RRSIG rdataset.

*create*, a ``bool``.  If True, create the rdataset if it is not found.

Returns a ``dns.rdataset.Rdataset`` or ``None``.
N)r>   r4   r9   s         r   get_rdatasetNode.get_rdatasetr   s;    4	$$WfEC 
  	C
	s    &&c                 f    U R                  XU5      nUb  U R                  R                  U5        gg)a  Delete the rdataset matching the specified properties in the
current node.

If a matching rdataset does not exist, it is not an error.

*rdclass*, an ``int``, the class of the rdataset.

*rdtype*, an ``int``, the type of the rdataset.

*covers*, an ``int``, the covered type.
N)rA   r   remove)r   r:   r;   r<   r   s        r   delete_rdatasetNode.delete_rdataset   s2     8?NN!!#& r   c                    [        U[        R                  R                  5      (       d  [	        S5      eU R                  UR                  UR                  UR                  5        U R                  R                  U5        g)a  Replace an rdataset.

It is not an error if there is no rdataset matching *replacement*.

Ownership of the *replacement* object is transferred to the node;
in other words, this method does not store a copy of *replacement*
at the node, it stores *replacement* itself.

*replacement*, a ``dns.rdataset.Rdataset``.

Raises ``ValueError`` if *replacement* is not a
``dns.rdataset.Rdataset``.
zreplacement is not an rdatasetN)
isinstancer5   r6   r7   
ValueErrorrE   r:   r;   r<   r   r8   )r   replacements     r   replace_rdatasetNode.replace_rdataset   s`     +s||'<'<===>>[00+2D2D(//	1k*r   r
   N)__name__
__module____qualname____firstlineno____doc__	__slots__r   r   r!   r&   r)   r,   r0   r5   	rdatatypeNONEr>   rA   rE   rK   __static_attributes__ r   r   r   r      sx    'I!$2
&#$ 58MM4F4F"!F 47==3E3E!@ 7:mm6H6H '"+r   r   )	rQ   ior   dns.rdatasetr5   dns.rdatatypedns.rendererobjectr   rV   r   r   <module>r\      s$   $ 0    [+6 [+r   