Your IP : 3.138.114.198


Current Path : /usr/lib/python3.6/site-packages/dns/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/dns/__pycache__/node.cpython-36.pyc

3

�b�W��@s<dZddlmZddlZddlZddlZGdd�de�ZdS)z)DNS nodes.  A node is a set of rdatasets.�)�StringIONc@s�eZdZdZdgZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zej
jdfdd�Zej
jdfdd�Zej
jfdd�Zdd�ZdS)�Nodez�A DNS node.

    A node is a set of rdatasets

    @ivar rdatasets: the node's rdatasets
    @type rdatasets: list of dns.rdataset.Rdataset objects�	rdatasetscCs
g|_dS)zInitialize a DNS node.
        N)r)�self�r�/usr/lib/python3.6/node.py�__init__$sz
Node.__init__cKsPt�}x8|jD].}t|�dkr|j|j|f|��|jd�qW|j�dd�S)a+Convert 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.
        @param name: the owner name of the rdatasets
        @type name: dns.name.Name object
        @rtype: string
        r�
N����)rr�len�write�to_text�getvalue)r�name�kw�s�rdsrrrr*s
zNode.to_textcCsdtt|��dS)Nz
<DNS node �>)�str�id)rrrr�__repr__;sz
Node.__repr__cCs@x|jD]}||jkrdSqWx|jD]}||jkr&dSq&WdS)zSTwo nodes are equal if they have the same rdatasets.

        @rtype: bool
        FT)r)r�otherZrdrrr�__eq__>s

zNode.__eq__cCs|j|�S)N)r)rrrrr�__ne__NszNode.__ne__cCs
t|j�S)N)rr)rrrr�__len__QszNode.__len__cCs
t|j�S)N)�iterr)rrrr�__iter__Tsz
Node.__iter__FcCsHx |jD]}|j|||�r|SqW|s*t�tjj||�}|jj|�|S)aFind an rdataset matching the specified properties in the
        current node.

        @param rdclass: The class of the rdataset
        @type rdclass: int
        @param rdtype: The type of the rdataset
        @type rdtype: int
        @param covers: 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.
        @type covers: int
        @param create: If True, create the rdataset if it is not found.
        @type create: bool
        @raises KeyError: An rdataset of the desired type and class does
        not exist and I{create} is not True.
        @rtype: dns.rdataset.Rdataset object
        )r�match�KeyError�dns�rdataset�Rdataset�append)r�rdclass�rdtype�covers�createrrrr�
find_rdatasetWszNode.find_rdatasetcCs2y|j||||�}Wntk
r,d}YnX|S)aEGet 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 I{create} is not True.

        @param rdclass: The class of the rdataset
        @type rdclass: int
        @param rdtype: The type of the rdataset
        @type rdtype: int
        @param covers: The covered type.
        @type covers: int
        @param create: If True, create the rdataset if it is not found.
        @type create: bool
        @rtype: dns.rdataset.Rdataset object or None
        N)r(r)rr$r%r&r'rrrr�get_rdatasetys

zNode.get_rdatasetcCs&|j|||�}|dk	r"|jj|�dS)azDelete the rdataset matching the specified properties in the
        current node.

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

        @param rdclass: The class of the rdataset
        @type rdclass: int
        @param rdtype: The type of the rdataset
        @type rdtype: int
        @param covers: The covered type.
        @type covers: int
        N)r)r�remove)rr$r%r&rrrr�delete_rdataset�szNode.delete_rdatasetcCs:t|tjj�std��|j|j|j|j�|j	j
|�dS)a8Replace an rdataset.

        It is not an error if there is no rdataset matching I{replacement}.

        Ownership of the I{replacement} object is transferred to the node;
        in other words, this method does not store a copy of I{replacement}
        at the node, it stores I{replacement} itself.
        zreplacement is not an rdatasetN)�
isinstancer r!r"�
ValueErrorr+r$r%r&rr#)rZreplacementrrr�replace_rdataset�s

zNode.replace_rdatasetN)�__name__�
__module__�__qualname__�__doc__�	__slots__rrrrrrrr Z	rdatatypeZNONEr(r)r+r.rrrrrs!r)	r2�iorZdns.rdatasetr Z
dns.rdatatypeZdns.renderer�objectrrrrr�<module>s


?>