U mf# @sNdZddlmZmZmZmZmZmZddlZ ddl Z ddl Z ddl Z Gddde j jZdee jjefeee jjefee jjefeeee jjee jjeee jjed dd Zee jjefeee jjefee jjefeed d d Zdee jjefeee jjee jjed ddZee jjefeeedddZdS)z)DNS RRsets (an RRset is a named rdataset))Any CollectionDictOptionalUnioncastNcs<eZdZdZddgZejjdfejj ej j ejj ejj e ej j dfdd Zfdd Zd d Zd d ZfddZeeedfdd Zd ejj ej j ejj ejj e ej j edfdd Zd!e ejj eeeefedfdd Zd"ee ejje ejj eeefedfdd ZejjdddZZ S)#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. namedeletingN)r rdclassrdtypecoversr cs t|||||_||_dS)zCreate a new RRset.N)super__init__r r selfr r r r r  __class__7/opt/hc_python/lib/python3.8/site-packages/dns/rrset.pyr(s zRRset.__init__cst}|j|_|j|_|SN)r_cloner r )robjrrrr6s z RRset._clonecCs|jdkrd}ndtj|jd}|jdk rDdtj|j}nd}dt|jdtj|jdtj|j ||d| d S) Nr()z delete=z) r dns rdatatypeto_textr rdataclassstrr r r Z _rdata_repr)rZctextZdtextrrr__repr__<s8      zRRset.__repr__cCs|Sr)r rrrr__str__Ssz RRset.__str__cs:t|tr|j|jkr.dSnt|tjjs.dSt|S)NF) isinstancerr rrdatasetRdatasetr__eq__)rotherrrrr)Vs   z RRset.__eq__)argskwargsreturncs0t|dtjjr|j||Stj||SdS)aDoes this rrset match the specified attributes? Behaves as :py:func:`full_match()` if the first argument is a ``dns.name.Name``, and as :py:func:`dns.rdataset.Rdataset.match()` otherwise. (This behavior fixes a design mistake where the signature of this method became incompatible with that of its superclass. The fix makes RRsets matchable as Rdatasets while preserving backwards compatibility.) rN)r&rr Name full_matchrmatch)rr+r,rrrr0^s  z RRset.match)r r r r r r-cs0t|||sdS|j|ks(|j|kr,dSdS)ztReturns ``True`` if this rrset matches the specified name, class, type, covers, and deletion state. FT)rr0r r rrrrr/os zRRset.full_matchT)origin relativizekwr-c stj|j|||jf|S)aConvert the RRset into DNS zone file format. See ``dns.name.Name.choose_relativity`` for more information on how *origin* and *relativize* determine the way names are emitted. Any additional keyword arguments are passed on to the rdata ``to_text()`` method. *origin*, a ``dns.name.Name`` or ``None``, the origin for relative names. *relativize*, a ``bool``. If ``True``, names will be relativized to *origin*. )rr r r )rr1r2r3rrrr sz RRset.to_text)filecompressr1r3r-c stj|j||||jf|S)zConvert the RRset to wire format. All keyword arguments are passed to ``dns.rdataset.to_wire()``; see that function for details. Returns an ``int``, the number of records emitted. )rto_wirer r )rr4r5r1r3rrrr6sz RRset.to_wire)r-cCstj|jt|S)zYConvert an RRset into an Rdataset. Returns a ``dns.rdataset.Rdataset``. )rr'from_rdata_listttllistr$rrr to_rdatasetszRRset.to_rdataset)N)NT)NN)!__name__ __module__ __qualname____doc__ __slots__rrNONEr r.r! RdataClass RdataTyperrrr#r%r)rboolr0r/rr"r Z CompressTypeintr6r'r(r: __classcell__rrrrrsV          rT) r r8r r text_rdatas idna_codecr1r2 relativize_tor-c Cst|trtjj|d|d}tjj|}tjj |}t |||} | ||D]*} tj | j | j| ||||} | | qR| S)ayCreate an RRset with the specified name, TTL, class, and type, and with the specified list of rdatas in text format. *idna_codec*, a ``dns.name.IDNACodec``, specifies the IDNA encoder/decoder to use; if ``None``, the default IDNA 2003 encoder/decoder is used. *origin*, a ``dns.name.Name`` (or ``None``), the origin to use for relative names. *relativize*, a ``bool``. If true, name will be relativized. *relativize_to*, a ``dns.name.Name`` (or ``None``), the origin to use when relativizing names. If not set, the *origin* value will be used. Returns a ``dns.rrset.RRset`` object. NrG)r&r"rr from_textr!rAmakerrBr update_ttlrdatar r add) r r8r r rFrGr1r2rHrtrdrrrfrom_text_lists$    rR)r r8r r rFr-cGst||||ttt|S)zCreate an RRset with the specified name, TTL, class, and type and with the specified rdatas in text format. Returns a ``dns.rrset.RRset`` object. )rRrrr")r r8r r rFrrrrJs  rJ)r r8rdatasrGr-cCszt|trtjj|d|d}t|dkr0tdd}|D]0}|dkr^t||j|j }| || |q8|dk svt |S)a/Create an RRset with the specified name and TTL, and with the specified list of rdata objects. *idna_codec*, a ``dns.name.IDNACodec``, specifies the IDNA encoder/decoder to use; if ``None``, the default IDNA 2003 encoder/decoder is used. Returns a ``dns.rrset.RRset`` object. NrIrzrdata list must not be empty) r&r"rr rJlen ValueErrorrr r rLrNAssertionError)r r8rSrGrOrQrrrr7s     r7)r r8rSr-cGst||tttjj|S)zCreate an RRset with the specified name and TTL, and with the specified rdata objects. Returns a ``dns.rrset.RRset`` object. )r7rrrrMRdata)r r8rSrrr from_rdatasrX)NNTN)N) r>typingrrrrrrZdns.namerZdns.rdataclassZ dns.rdatasetZ dns.rendererr'r(rr r.r"rDr!rArrBZ IDNACodecrCrRrJrMrWr7rXrrrrsN $    ,