AlkantarClanX12

Your IP : 3.12.146.100


Current Path : /proc/self/root/usr/lib/python3.6/site-packages/dns/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib/python3.6/site-packages/dns/__pycache__/rdataset.cpython-36.pyc

3

�b�W$-�@s�dZddlZddlmZddlZddlZddlZddlZddl	Zddl
ZddlmZej
jZGdd�dejj�ZGdd	�d	ejj�ZGd
d�dej
j�Zdd
�Zdd�Zdd�Zdd�ZdS)zHDNS rdatasets (an rdataset is a set of rdatas of a given type and class)�N)�StringIO�)�string_typesc@seZdZdZdS)�DifferingCoversz~An attempt was made to add a DNS SIG/RRSIG whose covered type
    is not the same as that of the other rdatas in the rdataset.N)�__name__�
__module__�__qualname__�__doc__�r
r
�/usr/lib/python3.6/rdataset.pyr!src@seZdZdZdS)�IncompatibleTypesz?An attempt was made to add DNS RR data of an incompatible type.N)rrrr	r
r
r
rr'srcs�eZdZdZddddgZejjf�fdd�	Z�fdd	�Z	d
d�Z
d$�fd
d�	Z�fdd�Z�fdd�Z
�fdd�Zdd�Zdd�Z�fdd�Zdd�Zd%dd�Zd&d d!�Zd"d#�Z�ZS)'�Rdataseta�A DNS rdataset.

    @ivar rdclass: The class of the rdataset
    @type rdclass: int
    @ivar rdtype: The type of the rdataset
    @type rdtype: int
    @ivar 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
    @ivar ttl: The DNS TTL (Time To Live) value
    @type ttl: int
    �rdclass�rdtype�covers�ttlcs*tt|�j�||_||_||_d|_dS)z�Create a new rdataset of the specified class and type.

        @see: the description of the class instance variables for the
        meaning of I{rdclass} and I{rdtype}rN)�superr
�__init__rrrr)�selfrrr)�	__class__r
rrCs
zRdataset.__init__cs2tt|�j�}|j|_|j|_|j|_|j|_|S)N)rr
�_clonerrrr)r�obj)rr
rrOszRdataset._clonecCs(t|�dkr||_n||jkr$||_dS)z�Set the TTL of the rdataset to be the lesser of the set's current
        TTL or the specified TTL.  If the set contains no rdatas, set the TTL
        to the specified TTL.
        @param ttl: The TTL
        @type ttl: intrN)�lenr)rrr
r
r�
update_ttlWs
zRdataset.update_ttlNcs�|j|jks|j|jkrt�|dk	r.|j|�|jtjjksJ|jtjjkr�|j�}t	|�dkrt|jtjj
krt||_n|j|kr�t�tjj|j�r�t	|�dkr�|j
�tt|�j|�dS)a%Add the specified rdata to the rdataset.

        If the optional I{ttl} parameter is supplied, then
        self.update_ttl(ttl) will be called prior to adding the rdata.

        @param rd: The rdata
        @type rd: dns.rdata.Rdata object
        @param ttl: The TTL
        @type ttl: intNr)rrrr�dns�	rdatatypeZRRSIGZSIGrr�NONErZis_singleton�clearrr
�add)r�rdrr)rr
rrcs

zRdataset.addcs |j|j�tt|�j|�dS)N)rrrr
�union_update)r�other)rr
rr �szRdataset.union_updatecs |j|j�tt|�j|�dS)N)rrrr
�intersection_update)rr!)rr
rr"�szRdataset.intersection_updatecs |j|j�tt|�j|�dS)z�Add all rdatas in other to self.

        @param other: The rdataset from which to update
        @type other: dns.rdataset.Rdataset objectN)rrrr
�update)rr!)rr
rr#�szRdataset.updatecCsR|jdkrd}ndtjj|j�d}dtjj|j�dtjj|j�|dS)Nr��(�)z<DNS � z
 rdataset>)rrr�to_text�
rdataclassrr)rZctextr
r
r�__repr__�s
zRdataset.__repr__cCs|j�S)N)r()rr
r
r�__str__�szRdataset.__str__csFt|t�sdS|j|jks2|j|jks2|j|jkr6dStt|�j|�S)zTwo rdatasets are equal if they have the same class, type, and
        covers, and contain the same rdata.
        @rtype: boolF)�
isinstancer
rrrr�__eq__)rr!)rr
rr-�s
zRdataset.__eq__cCs|j|�S)N)r-)rr!r
r
r�__ne__�szRdataset.__ne__Tc
Ks�|dk	r"|j||�}t|�}d}nd}d}t�}|dk	r>|}	n|j}	t|�dkrz|jd||tjj|	�tj	j|j
�f�nNxL|D]D}
|jd|||jtjj|	�tj	j|j
�|
jf||d�|��f�q�W|j�dd	�S)
a�Convert the rdataset into DNS master file format.

        @see: L{dns.name.Name.choose_relativity} for more information
        on how I{origin} and I{relativize} determine the way names
        are emitted.

        Any additional keyword arguments are passed on to the rdata
        to_text() method.

        @param name: If name is not None, emit a RRs with I{name} as
        the owner name.
        @type name: dns.name.Name object
        @param origin: The origin for relative names, or None.
        @type origin: dns.name.Name object
        @param relativize: True if names should names be relativized
        @type relativize: boolNr'r$rz
%s%s%s %s
z%s%s%d %s %s %s
)�origin�
relativizer���)
Zchoose_relativity�strrrr�writerr)r(rrr�getvalue)r�namer/r0�override_rdclass�kwZntextZpad�srrr
r
rr(�s*


zRdataset.to_textc
Cs&|dk	r|}d}n|j}|jdd�t|�dkr`|j|||�tjd|j|dd�}|j|�dS|rxt|�}	t	j
|	�n|}	x�|	D]�}
|j|||�tjd|j||jd�}|j|�|j�}|
j|||�|j�}||dks�t
�|j|d�tjd||�}|j|�|jdd�q�Wt|�SdS)	a,Convert the rdataset to wire format.

        @param name: The owner name of the RRset that will be emitted
        @type name: dns.name.Name object
        @param file: The file to which the wire format data will be appended
        @type file: file
        @param compress: The compression table to use; the default is None.
        @type compress: dict
        @param origin: The origin to be appended to any relative names when
        they are emitted.  The default is None.
        @returns: the number of records emitted
        @rtype: int
        NFr�z!HHIHriz!H)r�seekr�to_wire�struct�packrr3�list�randomZshuffler�tell�AssertionError)
rr5�file�compressr/r6Zwant_shufflerZstuff�lr�start�endr
r
rr;�s8




zRdataset.to_wirecCs&|j|kr"|j|kr"|j|kr"dSdS)zSReturns True if this rdataset matches the specified class, type,
        and coversTF)rrr)rrrrr
r
r�matchs



zRdataset.match)N)NNTN)NNNT)rrrr	�	__slots__rrrrrrrr r"r#r*r+r-r.r(r;rG�
__classcell__r
r
)rrr
,s$ 	

2
/r
cCspt|t�rtjj|�}t|t�r,tjj|�}t||�}|j|�x*|D]"}tjj|j	|j
|�}|j|�qFW|S)z�Create an rdataset with the specified class, type, and TTL, and with
    the specified list of rdatas in text format.

    @rtype: dns.rdataset.Rdataset object
    )r,rrr)�	from_textrr
rZrdatarrr)rrr�text_rdatas�r�trr
r
r�from_text_lists




rNcGst||||�S)z�Create an rdataset with the specified class, type, and TTL, and with
    the specified rdatas in text format.

    @rtype: dns.rdataset.Rdataset object
    )rN)rrrrKr
r
rrJ/srJcCsTt|�dkrtd��d}x6|D].}|dkrBt|j|j�}|j|�|j|�qW|S)z�Create an rdataset with the specified TTL, and with
    the specified list of rdata objects.

    @rtype: dns.rdataset.Rdataset object
    rzrdata list must not be emptyN)r�
ValueErrorr
rrrr)r�rdatasrLrr
r
r�from_rdata_list9s

rQcGs
t||�S)z�Create an rdataset with the specified TTL, and with
    the specified rdata objects.

    @rtype: dns.rdataset.Rdataset object
    )rQ)rrPr
r
r�
from_rdataKsrR)r	r?�iorr<Z
dns.exceptionrZ
dns.rdatatypeZdns.rdataclassZ	dns.rdataZdns.setZ_compatr�set�SetZ	SimpleSetZ	exceptionZDNSExceptionrrr
rNrJrQrRr
r
r
r�<module>s$q