3 ­$èWkã@sldZddlZddlZddlZddlZddlmZGdd„dejj ƒZ ddd„Z d d „Z dd d „Z d d„ZdS)z)DNS RRsets (an RRset is a named rdataset)éNé)Ú string_typescsŒeZdZdZddgZejjdf‡fdd„ Z‡fdd„Z d d „Z d d „Z ‡fd d„Z d‡fdd„ Z d‡fdd„ Zd‡fdd„ Zdd„Z‡ZS)ÚRRseta6A 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ÚdeletingNcs$tt|ƒj|||ƒ||_||_dS)zCreate a new RRset.N)ÚsuperrÚ__init__rr)ÚselfrÚrdclassÚrdtypeÚcoversr)Ú __class__©ú/usr/lib/python3.6/rrset.pyr'szRRset.__init__cs"tt|ƒjƒ}|j|_|j|_|S)N)rrÚ_clonerr)r Úobj)r rrr/sz RRset._clonecCs†|jdkrd}ndtjj|jƒd}|jdk rDdtjj|jƒ}nd}dt|jƒdtjj|jƒdtjj|j ƒ||dS) NrÚú(ú)z delete=z) r ÚdnsÚ rdatatypeÚto_textrÚ rdataclassÚstrrr r )r ZctextZdtextrrrÚ__repr__5s  zRRset.__repr__cCs|jƒS)N)r)r rrrÚ__str__Bsz RRset.__str__cs.t|tƒsdS|j|jkrdStt|ƒj|ƒS)zcTwo RRsets are equal if they have the same name and the same rdataset @rtype: boolF)Ú isinstancerrrÚ__eq__)r Úother)r rrrEs   z RRset.__eq__cs4tt|ƒj|||ƒsdS|j|ks,|j|kr0dSdS)zaReturns True if this rrset matches the specified class, type, covers, and deletion state.FT)rrÚmatchrr)r rr r r r)r rrr Ps z RRset.matchTc stt|ƒ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)rrrrr)r ÚoriginZ relativizeÚkw)r rrrZsz RRset.to_textc s tt|ƒj|j||||jf|ŽS)z!Convert the RRset to wire format.)rrÚto_wirerr)r ÚfileÚcompressr!r")r rrr#lsz RRset.to_wirecCstjj|jt|ƒƒS)zYConvert an RRset into an Rdataset. @rtype: dns.rdataset.Rdataset object )rÚrdatasetÚfrom_rdata_listÚttlÚlist)r rrrÚ to_rdatasetrszRRset.to_rdataset)N)NT)NN)Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú __slots__rrZNONErrrrrr rr#r*Ú __classcell__rr)r rrs     rc CsŽ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) rrrrÚ from_textrrrÚ update_ttlZrdatar r Úadd) rr(r r Ú text_rdatasr1ÚrÚtÚrdrrrÚfrom_text_listzs        r9cGst|||||ƒ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)rr(r r r5rrrr2�sr2cCsrt|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)r1rzrdata list must not be empty) rrrrr2ÚlenÚ ValueErrorrr r r3r4)rr(Úrdatasr1r6r8rrrr'šs    r'cGs t|||ƒS)zƒCreate an RRset with the specified name and TTL, and with the specified rdata objects. @rtype: dns.rrset.RRset object )r')rr(r<rrrÚ from_rdata¯sr=)N)N)r.Zdns.namerZ dns.rdatasetZdns.rdataclassZ dns.rendererZ_compatrr&ZRdatasetrr9r2r'r=rrrrÚs a