HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/dns/__pycache__/node.cpython-310.pyc
o

!wex1�@s�dZddlZddlZddlmZmZmZddlZddl	Zddl
ZddlZddlZddl
ZddlZejjhZejjejjejjhZdd�ZejGdd�dej��ZGdd	�d	�ZejjGd
d�de��ZdS)z)DNS nodes.  A node is a set of rdatasets.�N)�Any�Dict�OptionalcCs||vp
|tjjko
||vS�N)�dns�	rdatatype�RRSIG)�rdtypes�rdtype�covers�r�A/home/arjun/projects/env/lib/python3.10/site-packages/dns/node.py�_matches_type_or_its_signature,src@sXeZdZdZdZdZdZedej	j
dej	j
ddfdd	��Zed
ejj
ddfdd��Zd
S)�NodeKindzRdatasets in nodesr��r
r�returncCs*tt||�r	tjStt||�rtjStjSr)r�_cname_typesr�CNAME�_neutral_types�NEUTRAL�REGULAR)�clsr
rrrr
�classify8s
zNodeKind.classify�rdatasetcCs|�|j|j�Sr)rr
r)rrrrr
�classify_rdatasetCszNodeKind.classify_rdatasetN)�__name__�
__module__�__qualname__�__doc__rrr�classmethodrr�	RdataTyperr�Rdatasetrrrrr
r0s���
rc@sDeZdZdZdgZdd�Zdejjde	e
efde
fdd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zejjdfdejjdejjdejjdedejjf
dd�Zejjdfdejjdejjdejjdedeejjf
dd�Zejjfdejjdejjdejjddfd d!�Zd"ejjddfd#d$�Zde fd%d&�Z!defd'd(�Z"dS))�Nodea�A Node is a set of rdatasets.

    A node is either a CNAME node or an "other data" node.  A CNAME
    node contains only CNAME, KEY, NSEC, and NSEC3 rdatasets along with their
    covering RRSIG rdatasets.  An "other data" node contains any
    rdataset other than a CNAME or RRSIG(CNAME) rdataset.  When
    changes are made to a node, the CNAME or "other data" state is
    always consistent with the update, i.e. the most recent change
    wins.  For example, if you have a node which contains a CNAME
    rdataset, and then add an MX rdataset to it, then the CNAME
    rdataset will be deleted.  Likewise if you have a node containing
    an MX rdataset and add a CNAME rdataset, the MX rdataset will be
    deleted.
    �	rdatasetscCs
g|_dSr�r$��selfrrr
�__init__[s
z
Node.__init__�name�kwrcKsRt��}|jD]}t|�dkr |�|j|fi|���|�d�q|��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.

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

        Returns a ``str``.

        r�
N���)�io�StringIOr$�len�write�to_text�getvalue)r'r)r*�s�rdsrrr
r1_s

�zNode.to_textcCsdtt|��dS)Nz
<DNS node �>)�str�idr&rrr
�__repr__ssz
Node.__repr__cCs<|jD]
}||jvr
dSq|jD]
}||jvrdSqdS)NFTr%)r'�other�rdrrr
�__eq__vs

�

�zNode.__eq__cCs|�|�Sr)r;)r'r9rrr
�__ne__�szNode.__ne__cC�
t|j�Sr)r/r$r&rrr
�__len__��
zNode.__len__cCr=r)�iterr$r&rrr
�__iter__�r?z
Node.__iter__cCsbt|j�dkr)t�|�}|tjkrdd�|jD�|_n|tjkr)dd�|jD�|_|j�|�dS)a�Append rdataset to the node with special handling for CNAME and
        other data conditions.

        Specifically, if the rdataset being appended has ``NodeKind.CNAME``,
        then all rdatasets other than KEY, NSEC, NSEC3, and their covering
        RRSIGs are deleted.  If the rdataset being appended has
        ``NodeKind.REGULAR`` then CNAME and RRSIG(CNAME) are deleted.
        rcS� g|]}t�|�tjkr|�qSr)rrr��.0r4rrr
�
<listcomp>��
�z)Node._append_rdataset.<locals>.<listcomp>cSrBr)rrrrCrrr
rE�rFN)r/r$rrrr�append�r'r�kindrrr
�_append_rdataset�s



�
�zNode._append_rdatasetF�rdclassr
r�createcCsH|jD]
}|�|||�r|Sq|st�tj�|||�}|�|�|S)a*Find an rdataset matching the specified properties in the
        current node.

        *rdclass*, a ``dns.rdataclass.RdataClass``, the class of the rdataset.

        *rdtype*, a ``dns.rdatatype.RdataType``, the type of the rdataset.

        *covers*, a ``dns.rdatatype.RdataType``, 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�KeyErrorrrr"rJ�r'rKr
rrLr4rrr
�
find_rdataset�s
 �
zNode.find_rdatasetcCs0z|�||||�}W|Styd}Y|Sw)a�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)rPrNrOrrr
�get_rdataset�s��zNode.get_rdatasetNcCs*|�|||�}|dur|j�|�dSdS)aDDelete 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)rQr$�remove)r'rKr
rr4rrr
�delete_rdataset�s�zNode.delete_rdataset�replacementcCsNt|tjj�std��t|tjj�r|��}|�|j	|j
|j�|�|�dS)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``.
        zreplacement is not an rdatasetN)
�
isinstancerrr"�
ValueError�rrset�RRset�to_rdatasetrSrKr
rrJ�r'rTrrr
�replace_rdatasets�zNode.replace_rdatasetcCs4|jD]}t�|j|j�}|tjkr|SqtjS)aTClassify a node.

        A node which contains a CNAME or RRSIG(CNAME) is a
        ``NodeKind.CNAME`` node.

        A node which contains only "neutral" types, i.e. types allowed to
        co-exist with a CNAME, is a ``NodeKind.NEUTRAL`` node.  The neutral
        types are NSEC, NSEC3, KEY, and their associated RRSIGS.  An empty node
        is also considered neutral.

        A node which contains some rdataset which is not a CNAME, RRSIG(CNAME),
        or a neutral type is a a ``NodeKind.REGULAR`` node.  Regular nodes are
        also commonly referred to as "other data".
        )r$rrr
rrrHrrr
r%s

�z
Node.classifycC�dS)NFrr&rrr
�is_immutable:�zNode.is_immutable)#rrrr�	__slots__r(rr)�Namerr6rr1r8r;r<r>rArJr�NONE�
rdataclass�
RdataClassr!�boolrr"rPrrQrSr[rrr]rrrr
r#Hsd" �����
�-�����

�)����
�r#cs�eZdZ�fdd�Zejjdfdejjdejj	dejj	de
dejjf
�fd	d
�
Z
ejjdfdejjdejj	dejj	de
deejjf
�fdd�
Zejjfdejjdejj	dejj	dd
fdd�Zdejjdd
fdd�Zde
fdd�Z�ZS)�
ImmutableNodecs$t���tdd�|jD��|_dS)NcSsg|]}tj�|��qSr)rr�ImmutableRdatasetrCrrr
rECsz*ImmutableNode.__init__.<locals>.<listcomp>)�superr(�tupler$)r'�node��	__class__rr
r(@s

�zImmutableNode.__init__FrKr
rrLrc�|rtd��t��|||d�S�N�	immutableF)�	TypeErrorrgrP�r'rKr
rrLrjrr
rPF�zImmutableNode.find_rdatasetcrlrm)rorgrQrprjrr
rQQrqzImmutableNode.get_rdatasetNcC�td���Nrn�ro)r'rKr
rrrr
rS\szImmutableNode.delete_rdatasetrTcCrrrsrtrZrrr
r[dszImmutableNode.replace_rdatasetcCr\)NTrr&rrr
r]gr^zImmutableNode.is_immutable)rrrr(rrrarbrcr!rdrr"rPrrQrSr[r]�
__classcell__rrrjr
re>sP
�����������
�����
�re)r�enumr-�typingrrr�
dns.immutabler�dns.name�dns.rdataclass�dns.rdataset�
dns.rdatatype�dns.renderer�	dns.rrsetrrr�NSEC�NSEC3�KEYrr�unique�Enumrr#rnrerrrr
�<module>s0��w