3
$èWk ã @ sl d Z ddlZddlZddlZddlZddlmZ G dd„ dejj ƒZ
ddd„Zd d
„ Zddd„Z
d
d„ ZdS )z)DNS RRsets (an RRset is a named rdataset)é Né )Ústring_typesc sŒ e Zd ZdZddgZejjdf‡ fdd„ Z‡ fdd„Z d d
„ Z
dd„ Z‡ fd
d„Zd‡ fdd„ Z
d‡ fdd„ Zd‡ fdd„ Zdd„ Z‡ ZS )Ú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|||ƒ || _|| _dS )zCreate a new RRset.N)Úsuperr Ú__init__r r )Úselfr ÚrdclassÚrdtypeÚcoversr )Ú __class__© ú/usr/lib/python3.6/rrset.pyr ' s zRRset.__init__c s" t t| ƒjƒ }| j|_| j|_|S )N)r r Ú_cloner r )r Úobj)r
r r r / s zRRset._clonec C s† | j dkrd}ndtjj| j ƒ d }| jd k rDdtjj| jƒ }nd}dt| jƒ d tjj| jƒ d tjj| j ƒ | | d S ) Nr Ú ú(ú)z delete=z)
r ÚdnsÚ rdatatypeÚto_textr Ú
rdataclassÚstrr r
r )r ZctextZdtextr r r Ú__repr__5 s
zRRset.__repr__c C s | j ƒ S )N)r )r r r r Ú__str__B s z
RRset.__str__c s. t |tƒsdS | j|jkrdS tt| ƒ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
zRRset.__eq__c s4 t t| ƒj|||ƒsdS | j|ks,| j|kr0dS dS )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
zRRset.matchTc s t t| ƒj| j||| jf|Ž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|||| jf|Ž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 jj| jt| ƒƒ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 zRRset.to_rdataset)N)NT)NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú __slots__r r ZNONEr r r r r r r r# r* Ú
__classcell__r r )r
r r s
r c C sŽ t | tƒrtjj| d|d�} t |tƒr2tjj|ƒ}t |tƒrHtjj|ƒ}t| ||ƒ}|j|ƒ x*|D ]"}tj 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_ttlZrdatar
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ƒrtjj| d|d�} t|ƒdkr0tdƒ‚d}x8|D ]0}|dkr`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 zrdata 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<