o
    Þý°j©#  ã                   @   sj  d Z ddlmZmZmZmZ ddlZddlZddl	Zddl
ZddlZddlZG dd„ dejjƒZ				ddejjeB ded	ejjeB d
ejjeB dee dejjdB dejjdB dedejjdB defdd„ZdejjeB ded	ejjeB d
ejjeB dedefdd„Z	ddejjeB dedeejj dejjdB def
dd„ZdejjeB dededefdd„ZdS )z)DNS RRsets (an RRset is a named rdataset)é    )ÚAnyÚ
CollectionÚDictÚcastNc                       sj  e Zd ZdZddgZejjdfdejj	dej
jdejjdejjdej
jdB f
‡ fdd	„Z‡ fd
d„Zdd„ Zdd„ Z‡ fdd„Zdededef‡ fdd„Z	d%dejj	dej
jdejjdejjdej
jdB def‡ fdd„Z		d&dejj	dB dedeeef def‡ fdd„Z		d'ded ejjdB dejj	dB deeef def
‡ fd!d"„Zdejjf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ÚdeletingNÚrdclassÚrdtypeÚcoversc                    s    t ƒ  |||¡ || _|| _dS )zCreate a new RRset.N)ÚsuperÚ__init__r   r   ©Úselfr   r	   r
   r   r   ©Ú	__class__© ú|/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/dns/rrset.pyr   *   s   

zRRset.__init__c                    s$   t ttƒ  ¡ ƒ}| j|_| j|_|S ©N)r   r   r   Ú_cloner   r   )r   Úobjr   r   r   r   8   s   zRRset._clonec                 C   s’   | j dkrd}ndtj | j ¡ d }| jd ur"dtj | j¡ }nd}dt| jƒ d tj | j¡ d tj | j	¡ | | d |  
¡  d	 S )
Nr   Ú ú(ú)z delete=z<DNS ú z RRset: ú>)r   ÚdnsÚ	rdatatypeÚto_textr   Ú
rdataclassÚstrr   r	   r
   Ú_rdata_repr)r   ÚctextÚdtextr   r   r   Ú__repr__>   s8   

ÿþýüûúùø	÷
öÿzRRset.__repr__c                 C   s   |   ¡ S r   )r   ©r   r   r   r   Ú__str__U   s   zRRset.__str__c                    s:   t |tƒr| j|jkrdS n	t |tjjƒsdS tƒ  |¡S )NF)Ú
isinstancer   r   r   ÚrdatasetÚRdatasetr   Ú__eq__)r   Úotherr   r   r   r*   X   s   
ÿzRRset.__eq__ÚargsÚkwargsÚreturnc                    s4   t |d tjjƒr| j|i |¤ŽS tƒ j|i |¤ŽS )aÐ  Does 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.)
        r   )r'   r   r   ÚNameÚ
full_matchr   Úmatch)r   r,   r-   r   r   r   r1   `   s   zRRset.matchc                    s0   t ƒ  |||¡s
dS | j|ks| j|krdS dS )ztReturns ``True`` if this rrset matches the specified name, class,
        type, covers, and deletion state.
        FT)r   r1   r   r   r   r   r   r   r0   q   s
   zRRset.full_matchTÚoriginÚ
relativizeÚkwc                    s   t ƒ j| j||| jfi |¤ŽS )aï  Convert 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*.
        )r   r   r   r   )r   r2   r3   r4   r   r   r   r   „   s
   ÿÿzRRset.to_textÚfileÚcompressc                    s    t ƒ j| j|||| jfi |¤ŽS )zÖConvert 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.
        )r   Úto_wirer   r   )r   r5   r6   r2   r4   r   r   r   r7   ž   s
   ÿÿzRRset.to_wirec                 C   s   t j | jt| ƒ¡S )zYConvert an RRset into an Rdataset.

        Returns a ``dns.rdataset.Rdataset``.
        )r   r(   Úfrom_rdata_listÚttlÚlistr%   r   r   r   Úto_rdataset³   s   zRRset.to_rdatasetr   )NT)NN) Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   ÚNONEr   r/   r   Ú
RdataClassÚ	RdataTyper   r   r$   r&   r*   r   Úboolr1   r0   r   r    r   ÚCompressTypeÚintr7   r(   r)   r;   Ú__classcell__r   r   r   r   r      sx    	úþýüû
úúþýüû
úùý
þý
üûüþ
ý
ü
ûúr   Tr   r9   r	   r
   Útext_rdatasÚ
idna_codecr2   r3   Úrelativize_tor.   c	              
   C   s‚   t | tƒrtjj| d|d�} tjj |¡}tjj	 |¡}t
| ||ƒ}	|	 |¡ |D ]}
tj |	j|	j|
||||¡}|	 |¡ q)|	S )ay  Create 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.
    N©rI   )r'   r    r   r   Ú	from_textr   rB   Úmaker   rC   r   Ú
update_ttlÚrdatar	   r
   Úadd)r   r9   r	   r
   rH   rI   r2   r3   rJ   ÚrÚtÚrdr   r   r   Úfrom_text_list»   s   

ÿrT   c                 G   s   t | |||ttt |ƒƒS )zŸCreate an RRset with the specified name, TTL, class, and type and with
    the specified rdatas in text format.

    Returns a ``dns.rrset.RRset`` object.
    )rT   r   r   r    )r   r9   r	   r
   rH   r   r   r   rL   æ   s   ÿrL   Úrdatasc                 C   sz   t | tƒrtjj| d|d�} t|ƒdkrtdƒ‚d}|D ]}|du r/t| |j|j	ƒ}| 
|¡ | |¡ q|dus;J ‚|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.

    NrK   r   zrdata list must not be empty)r'   r    r   r   rL   ÚlenÚ
ValueErrorr   r	   r
   rN   rP   )r   r9   rU   rI   rQ   rS   r   r   r   r8   ø   s   

r8   c                 G   s   t | |tttjj |ƒƒS )zŠCreate an RRset with the specified name and TTL, and with
    the specified rdata objects.

    Returns a ``dns.rrset.RRset`` object.
    )r8   r   r   r   rO   ÚRdata)r   r9   rU   r   r   r   Ú
from_rdata  s   rY   )NNTNr   ) r?   Útypingr   r   r   r   Údns.namer   Ú	dns.rdataÚdns.rdataclassÚdns.rdatasetÚdns.rdatatypeÚdns.rendererr(   r)   r   r   r/   r    rF   r   rB   r   rC   Ú	IDNACodecrD   rT   rL   rO   rX   r8   rY   r   r   r   r   Ú<module>   sz    $÷
ÿþ
ý
üû
ú
ùø
	÷

ö+
ÿþ
ý
üû
úü
ÿþ
ý
ü
û& 