o
    'h#                     @   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 python not having a set class, and
    originally the class used lists in its implementation.  The ordered and indexable
    nature of RRsets and Rdatasets is unfortunately widely used in dnspython
    applications, so for backwards compatibility sets continue to be a custom class, now
    based on an ordered dictionary.
    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   C/var/www/html/olx_land/venv/lib/python3.10/site-packages/dns/set.py__init__!   s   zSet.__init__c                 C   s   dt t| j  dS )Nzdns.set.Set())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   1   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	   remove7   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   D   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	   _cloneI   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	   copyd   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_updatei   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_updateu   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   r0   intersectionr.   r1   )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   r5   )zReturn a new set which is the intersection of ``self`` and
        ``other``.

        Returns the same Set type as this set.
        )r#   r/   r6   r   r   r	   r2         
zSet.intersectionc                 C   r5   )zReturn 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#   r1   r6   r   r   r	   
difference   r8   zSet.differencec                 C   r5   )zReturn 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#   r4   r6   r   r   r	   symmetric_difference   s   
zSet.symmetric_differencec                 C   
   |  |S Nr7   r   r-   r   r   r	   __or__      
z
Set.__or__c                 C   r;   r<   )r2   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<   )r9   r>   r   r   r	   __sub__   r@   zSet.__sub__c                 C   r;   r<   )r:   r>   r   r   r	   __xor__   r@   zSet.__xor__c                 C      |  | | S r<   r.   r>   r   r   r	   __ior__      
zSet.__ior__c                 C   rE   r<   )r/   r>   r   r   r	   __iand__   rH   zSet.__iand__c                 C   rE   r<   rF   r>   r   r   r	   __iadd__   rH   zSet.__iadd__c                 C   rE   r<   )r1   r>   r   r   r	   __isub__   rH   zSet.__isub__c                 C   rE   r<   )r4   r>   r   r   r	   __ixor__   rH   zSet.__ixor__c                 C   s   |D ]}|  | qdS )zUpdate 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   r0   r   r   r   r	   r0      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<   )rM   r>   r   r   r	   __ne__   rN   z
Set.__ne__c                 C   
   t | jS r<   )lenr   r   r   r   r	   __len__  r@   zSet.__len__c                 C   rP   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+   rV   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*   FTra   r,   r   r   r	   
issuperset!  rc   zSet.issupersetc                 C   s2   t |ts	td|jD ]
}|| jv r dS qdS )Nr*   FTra   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/   r1   r4   r7   r2   r9   r:   r?   rA   rB   rC   rD   rG   rI   rJ   rK   rL   r    r0   rM   rO   rR   rT   r^   r`   rb   rd   re   r   r   r   r	   r      sR    	


r   )rW   r   r   r   r   r	   <module>   s   