o
    «ïg€#  ã                   @   s   d dl Z G dd„ dƒZdS )é    Nc                   @   sJ  e Zd ZdZdgZdQdd„Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dRdd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Z d=d>„ Z!d?d@„ Z"dAdB„ Z#dCdD„ Z$dEdF„ Z%dGdH„ Z&dIdJ„ Z'dKdL„ Z(dMdN„ Z)dOdP„ Z*dS )SÚSeta!  A simple set class.

    This class was originally used to deal with sets being missing in
    ancient versions of python, but dnspython will continue to use it
    as these sets are based on lists and are thus indexable, and this
    ability is widely used in dnspython applications.
    ÚitemsNc                 C   s,   t ƒ | _|dur|D ]	}|  |¡ q
dS dS )zaInitialize the set.

        *items*, an iterable or ``None``, the initial set of items.
        N)Údictr   Úadd)Úselfr   Úitem© r   úT/var/www/html/portale_awareness/portale-venv/lib/python3.10/site-packages/dns/set.pyÚ__init__    s   üzSet.__init__c                 C   s   dt t| j ¡ ƒƒ S )Nzdns.set.Set(%s))ÚreprÚlistr   Úkeys©r   r   r   r	   Ú__repr__-   s   zSet.__repr__c                 C   s   || j vrd| j |< dS dS )zAdd an item to the set.N©r   ©r   r   r   r   r	   r   0   s   
ÿzSet.addc                 C   s"   z| j |= W dS  ty   t‚w )zRemove an item from the set.N)r   ÚKeyErrorÚ
ValueErrorr   r   r   r	   Úremove6   s
   ÿz
Set.removec                 C   s   | j  |d¡ dS )z'Remove an item from the set if present.N)r   Úpopr   r   r   r	   Údiscard>   s   zSet.discardc                 C   s   | j  ¡ \}}|S )z&Remove an arbitrary item from the set.)r   Úpopitem)r   ÚkÚ_r   r   r	   r   C   s   zSet.popÚreturnc                 C   s<   t | dƒr	| j}n| j}| |¡}tƒ |_|j | j¡ |S )aÞ  Make a (shallow) copy of the set.

        There is a 'clone protocol' that subclasses of this class
        should use.  To make a copy, first call your super's _clone()
        method, and use the object returned as the new instance.  Then
        make shallow copies of the attributes defined in the subclass.

        This protocol allows us to write the set algorithms that
        return new instances (e.g. union) once, and keep using them in
        subclasses.
        Ú_clone_class)Úhasattrr   Ú	__class__Ú__new__r   r   Úupdate)r   ÚclsÚobjr   r   r	   Ú_cloneH   s   

z
Set._clonec                 C   ó   |   ¡ S ©z!Make a (shallow) copy of the set.©r"   r   r   r   r	   Ú__copy__^   ó   zSet.__copy__c                 C   r#   r$   r%   r   r   r   r	   Úcopyc   r'   zSet.copyc                 C   s8   t |tƒs	tdƒ‚| |u rdS |jD ]}|  |¡ qdS )zaUpdate the set, adding any elements from other which are not
        already in the set.
        úother must be a Set instanceN)Ú
isinstancer   r   r   r   ©r   Úotherr   r   r   r	   Úunion_updateh   s   

ÿzSet.union_updatec                 C   sD   t |tƒs	tdƒ‚| |u rdS t| jƒD ]}||jvr| j|= qdS )z]Update the set, removing any elements from other which are not
        in both sets.
        r)   N)r*   r   r   r   r   r+   r   r   r	   Úintersection_updatet   s   

€þzSet.intersection_updatec                 C   sB   t |tƒs	tdƒ‚| |u r| j ¡  dS |jD ]}|  |¡ qdS )zWUpdate the set, removing any elements from other which are in
        the set.
        r)   N)r*   r   r   r   Úclearr   r+   r   r   r	   Údifference_updateƒ   s   

ÿzSet.difference_updatec                 C   sJ   t |tƒs	tdƒ‚| |u r| j ¡  dS |  |¡}|  |¡ |  |¡ dS )z<Update the set, retaining only elements unique to both sets.r)   N)r*   r   r   r   r/   Úintersectionr-   r0   )r   r,   Úoverlapr   r   r	   Úsymmetric_difference_update   s   


zSet.symmetric_difference_updatec                 C   ó   |   ¡ }| |¡ |S )zwReturn a new set which is the union of ``self`` and ``other``.

        Returns the same Set type as this set.
        )r"   r-   ©r   r,   r!   r   r   r	   Úunionœ   s   
z	Set.unionc                 C   r4   )z†Return a new set which is the intersection of ``self`` and
        ``other``.

        Returns the same Set type as this set.
        )r"   r.   r5   r   r   r	   r1   ¦   ó   
zSet.intersectionc                 C   r4   )z©Return a new set which ``self`` - ``other``, i.e. the items
        in ``self`` which are not also in ``other``.

        Returns the same Set type as this set.
        )r"   r0   r5   r   r   r	   Ú
difference±   r7   zSet.differencec                 C   r4   )zëReturn a new set which (``self`` - ``other``) | (``other``
        - ``self), ie: the items in either ``self`` or ``other`` which
        are not contained in their intersection.

        Returns the same Set type as this set.
        )r"   r3   r5   r   r   r	   Úsymmetric_difference¼   s   
zSet.symmetric_differencec                 C   ó
   |   |¡S ©N©r6   ©r   r,   r   r   r	   Ú__or__È   ó   
z
Set.__or__c                 C   r:   r;   )r1   r=   r   r   r	   Ú__and__Ë   r?   zSet.__and__c                 C   r:   r;   r<   r=   r   r   r	   Ú__add__Î   r?   zSet.__add__c                 C   r:   r;   )r8   r=   r   r   r	   Ú__sub__Ñ   r?   zSet.__sub__c                 C   r:   r;   )r9   r=   r   r   r	   Ú__xor__Ô   r?   zSet.__xor__c                 C   ó   |   |¡ | S r;   ©r-   r=   r   r   r	   Ú__ior__×   ó   
zSet.__ior__c                 C   rD   r;   )r.   r=   r   r   r	   Ú__iand__Û   rG   zSet.__iand__c                 C   rD   r;   rE   r=   r   r   r	   Ú__iadd__ß   rG   zSet.__iadd__c                 C   rD   r;   )r0   r=   r   r   r	   Ú__isub__ã   rG   zSet.__isub__c                 C   rD   r;   )r3   r=   r   r   r	   Ú__ixor__ç   rG   zSet.__ixor__c                 C   s   |D ]}|   |¡ qdS )zÑUpdate the set, adding any elements from other which are not
        already in the set.

        *other*, the collection of items with which to update the set, which
        may be any iterable type.
        N)r   r+   r   r   r	   r   ë   s   ÿz
Set.updatec                 C   s   | j  ¡  dS )zMake the set empty.N)r   r/   r   r   r   r	   r/   ö   s   z	Set.clearc                 C   s   | j |j kS r;   r   r=   r   r   r	   Ú__eq__ú   ó   z
Set.__eq__c                 C   s   |   |¡ S r;   )rL   r=   r   r   r	   Ú__ne__ý   rM   z
Set.__ne__c                 C   ó
   t | jƒS r;   )Úlenr   r   r   r   r	   Ú__len__   r?   zSet.__len__c                 C   rO   r;   )Úiterr   r   r   r   r	   Ú__iter__  r?   zSet.__iter__c                 C   s>   t |tƒrtt | j|j|j|j¡ƒS t	t | j||d ¡ƒS )Né   )
r*   Úslicer   Ú	itertoolsÚislicer   ÚstartÚstopÚstepÚnext)r   Úir   r   r	   Ú__getitem__  s   
zSet.__getitem__c                 C   s8   t |tƒrt| | ƒD ]}| j|= qd S | j| | = d S r;   )r*   rU   r   r   )r   r\   Úeltr   r   r	   Ú__delitem__  s
   

ÿzSet.__delitem__c                 C   s2   t |tƒs	tdƒ‚| jD ]
}||jvr dS qdS )zFIs this set a subset of *other*?

        Returns a ``bool``.
        r)   FT©r*   r   r   r   r+   r   r   r	   Úissubset  ó   


ÿzSet.issubsetc                 C   s2   t |tƒs	tdƒ‚|jD ]
}|| jvr dS qdS )zHIs this set a superset of *other*?

        Returns a ``bool``.
        r)   FTr`   r+   r   r   r	   Ú
issuperset   rb   zSet.issupersetc                 C   s2   t |tƒs	tdƒ‚|jD ]
}|| jv r dS qdS )Nr)   FTr`   r+   r   r   r	   Ú
isdisjoint-  s   


ÿzSet.isdisjointr;   )r   r   )+Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r
   r   r   r   r   r   r"   r&   r(   r-   r.   r0   r3   r6   r1   r8   r9   r>   r@   rA   rB   rC   rF   rH   rI   rJ   rK   r   r/   rL   rN   rQ   rS   r]   r_   ra   rc   rd   r   r   r   r	   r      sR    


r   )rV   r   r   r   r   r	   Ú<module>   s   