509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
­$èWk  ã               @   sl   d Z ddlZddlZddlZddlZddlmZ G dd„ dejj	ƒZ
ddd„Zd	d
„ Zddd„Zdd„ ZdS )z)DNS RRsets (an RRset is a named rdataset)é    Né   )Ústring_typesc                   sŒ   e Zd ZdZddgZejjdf‡ fdd„	Z‡ fdd„Z	d	d
„ Z
dd„ Z‡ fdd„Zd‡ fdd„	Zd‡ fdd„	Zd‡ fdd„	Zdd„ Z‡  ZS )ÚRRseta6  A DNS RRset (named rdataset).

    RRset inherits from Rdataset, and RRsets can be treated as
    Rdatasets in most cases.  There are, however, a few notable
    exceptions.  RRsets have different to_wire() and to_text() method
    arguments, reflecting the fact that RRsets always have an owner
    name.
    ÚnameÚdeletingNc                s$   t t| ƒj|||ƒ || _|| _dS )zCreate a new RRset.N)Úsuperr   Ú__init__r   r   )Úselfr   ÚrdclassÚrdtypeÚcoversr   )Ú	__class__© ú/usr/lib/python3.6/rrset.pyr   '   s    zRRset.__init__c                s"   t t| ƒjƒ }| j|_| j|_|S )N)r   r   Ú_cloner   r   )r	   Úobj)r   r   r   r   /   s    zRRset._clonec             C   s†   | j dkrd}ndtjj| j ƒ d }| jd k	rDdtjj| jƒ }nd}dt| jƒ d tjj| jƒ d tjj| j	ƒ | | d S )	Nr   Ú ú(ú)z delete=z<DNS ú z RRset>)
r   ÚdnsÚ	rdatatypeÚto_textr   Ú
rdataclassÚstrr   r
   r   )r	   ZctextZdtextr   r   r   Ú__repr__5   s    

zRRset.__repr__c             C   s   | j ƒ S )N)r   )r	   r   r   r   Ú__str__B   s    zRRset.__str__c                s.   t |tƒsdS | j|jkrdS tt| ƒj|ƒS )zcTwo RRsets are equal if they have the same name and the same
        rdataset

        @rtype: boolF)Ú
isinstancer   r   r   Ú__eq__)r	   Úother)r   r   r   r   E   s
    
zRRset.__eq__c                s4   t t| ƒj|||ƒsdS | j|ks,| j|kr0dS dS )zaReturns True if this rrset matches the specified class, type,
        covers, and deletion state.FT)r   r   Úmatchr   r   )r	   r   r
   r   r   r   )r   r   r   r    P   s
    zRRset.matchTc                s   t t| ƒj| j||| jf|ŽS )aû  Convert the RRset 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 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: bool)r   r   r   r   r   )r	   ÚoriginZ
relativizeÚkw)r   r   r   r   Z   s    zRRset.to_textc                s    t t| ƒj| j|||| jf|ŽS )z!Convert the RRset to wire format.)r   r   Úto_wirer   r   )r	   ÚfileÚcompressr!   r"   )r   r   r   r#   l   s    zRRset.to_wirec             C   s   t jj| jt| ƒƒS )zYConvert an RRset into an Rdataset.

        @rtype: dns.rdataset.Rdataset object
        )r   ÚrdatasetÚfrom_rdata_listÚttlÚlist)r	   r   r   r   Úto_rdatasetr   s    zRRset.to_rdataset)N)NT)NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   ZNONEr   r   r   r   r   r    r   r#   r*   Ú__classcell__r   r   )r   r   r      s   	
r   c       	      C   sŽ   t | tƒrtjj| d|d�} t |tƒr2tjj|ƒ}t |tƒrHtjj|ƒ}t| ||ƒ}|j|ƒ x*|D ]"}tj	j|j
|j|ƒ}|j|ƒ qdW |S )z¡Create an RRset with the specified name, TTL, class, and type, and with
    the specified list of rdatas in text format.

    @rtype: dns.rrset.RRset object
    N)Ú
idna_codec)r   r   r   r   Ú	from_textr   r   r   Ú
update_ttlZrdatar
   r   Úadd)	r   r(   r
   r   Útext_rdatasr1   ÚrÚtÚrdr   r   r   Úfrom_text_listz   s    




r9   c             G   s   t | ||||ƒS )z˜Create an RRset with the specified name, TTL, class, and type and with
    the specified rdatas in text format.

    @rtype: dns.rrset.RRset object
    )r9   )r   r(   r
   r   r5   r   r   r   r2   �   s    r2   c             C   sr   t | tƒrtjj| d|d�} t|ƒdkr0tdƒ‚d}x8|D ]0}|dkr`t| |j|j	ƒ}|j
|ƒ |j|ƒ q:W |S )z‹Create an RRset with the specified name and TTL, and with
    the specified list of rdata objects.

    @rtype: dns.rrset.RRset object
    N)r1   r   zrdata list must not be empty)r   r   r   r   r2   ÚlenÚ
ValueErrorr   r
   r   r3   r4   )r   r(   Úrdatasr1   r6   r8   r   r   r   r'   š   s    


r'   c             G   s   t | ||ƒS )zƒCreate an RRset with the specified name and TTL, and with
    the specified rdata objects.

    @rtype: dns.rrset.RRset object
    )r'   )r   r(   r<   r   r   r   Ú
from_rdata¯   s    r=   )N)N)r.   Zdns.namer   Zdns.rdatasetZdns.rdataclassZdns.rendererZ_compatr   r&   ZRdatasetr   r9   r2   r'   r=   r   r   r   r   Ú<module>   s   a


