o
    hJA                     @  s  d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dlm
Z
 d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ ddlmZ ededZededZededZededZG dd dZG dd dee
eef ZG dd  d eeef ZG d!d" d"ee ZG d#d$ d$Z 	%d.d/d,d-Z!d%S )0    )annotations)filterfalse)AbstractSet)Any)Callable)cast)
Collection)Dict)Iterable)Iterator)List)Mapping)NoReturn)Optional)Set)Tuple)TYPE_CHECKING)TypeVar)Union   )Self_T)bound_S_KT_VTc                   @  sB   e Zd ZdZdddZdd	d
ZdddZdddZdddZdS )ReadOnlyContainer argr   kwreturnr   c                 O     t d| jj )Nz&%s object is immutable and/or readonly	TypeError	__class____name__selfr   r   r   r   s/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sqlalchemy/util/_py_collections.py	_readonly)   s   
zReadOnlyContainer._readonlyc                 O  r!   )Nz%s object is immutabler"   r&   r   r   r(   
_immutable.      zReadOnlyContainer._immutablekeyc                 C     |    d S Nr)   r'   r,   r   r   r(   __delitem__1      zReadOnlyContainer.__delitem__valuec                 C  r-   r.   r/   r'   r,   r3   r   r   r(   __setitem__4   r2   zReadOnlyContainer.__setitem__strc                 C  r-   r.   r/   r4   r   r   r(   __setattr__7   r2   zReadOnlyContainer.__setattr__Nr   r   r   r   r    r   )r,   r   r    r   )r,   r   r3   r   r    r   )r,   r6   r3   r   r    r   )	r%   
__module____qualname__	__slots__r)   r*   r1   r5   r7   r   r   r   r(   r   &   s    



r   c                   @  sd   e Zd ZerdddZdddZdddZdddZd d!ddZdddZ	d d!ddZ
dddZdS )"ImmutableDictBaseargsr   r    r   c                 G     d S r.   r   clsr=   r   r   r(   __new__>       zImmutableDictBase.__new__c                 G  r>   r.   r   r?   r   r   r(   __init__@   rB   zImmutableDictBase.__init__r   r   r   c                 O  r-   r.   )r*   r&   r   r   r(   r)   B   r2   zImmutableDictBase._readonlyc                 C  r-   r.   r/   r'   r   r   r(   clearE   r2   zImmutableDictBase.clearNr,   defaultOptional[Any]c                 C  r-   r.   r/   r'   r,   rF   r   r   r(   popH   r2   zImmutableDictBase.popc                 C  r-   r.   r/   rD   r   r   r(   popitemK   r2   zImmutableDictBase.popitemc                 C  r-   r.   r/   rH   r   r   r(   
setdefaultN   r2   zImmutableDictBase.setdefaultc                 O  r-   r.   r/   r&   r   r   r(   updateQ   r2   zImmutableDictBase.update)r=   r   r    r   )r=   r   r8   r    r   r.   )r,   r   rF   rG   r    r   )r%   r9   r:   r   rA   rC   r)   rE   rI   rJ   rK   rL   r   r   r   r(   r<   ;   s    




r<   c                      s   e Zd Zdd Zd$ddZdd Z		d%d&ddZ		d%d'ddZd(ddZd)ddZ	d*ddZ
d+ fd d!Zd+ fd"d#Z  ZS ),immutabledictc                 G  s    t | }tj|g|R   |S r.   )r<   rA   dictrC   )r@   r=   newr   r   r(   rA   V   s   
zimmutabledict.__new__r=   3Union[Mapping[_KT, _VT], Iterable[Tuple[_KT, _VT]]]c                 G  r>   r.   r   )r'   r=   r   r   r(   rC   [   s   zimmutabledict.__init__c                 C  s   t t| ffS r.   )rN   rO   rD   r   r   r(   
__reduce__`      zimmutabledict.__reduce__N_immutabledict__dOptional[Mapping[_KT, _VT]]r    immutabledict[_KT, _VT]c                 C  s0   |s| S t | j}t||  t|| |S r.   r<   rA   r$   rO   rC   rL   )r'   rT   rP   r   r   r(   unionc   s   zimmutabledict.unionr   r   c                 K  sD   |s|s| S t | j}t||  |rt|| t|| |S r.   rW   )r'   rT   r   rP   r   r   r(   _union_w_kwn   s   zimmutabledict._union_w_kwdictsc                 G  sN   d }|D ]}|r|d u rt | j}t||  t|| q|d u r%| S |S r.   rW   )r'   rZ   rP   dr   r   r(   
merge_with|   s   zimmutabledict.merge_withr6   c                 C  s   dt |  S )Nzimmutabledict(%s))rO   __repr__rD   r   r   r(   r]      rS   zimmutabledict.__repr___immutabledict__valuer   r   c                 C  r-   r.   r/   r'   r^   r   r   r(   __ior__   r2   zimmutabledict.__ior__Mapping[_KT, _VT]c                      t t |S r.   )rN   super__or__r_   r$   r   r(   rd         
zimmutabledict.__or__c                   rb   r.   )rN   rc   __ror__r_   re   r   r(   rg      rf   zimmutabledict.__ror__)r=   rQ   r.   )rT   rU   r    rV   )rT   rU   r   r   r    rV   )rZ   rU   r    rV   r    r6   )r^   r   r    r   )r^   ra   r    rV   )r%   r9   r:   rA   rC   rR   rX   rY   r\   r]   r`   rd   rg   __classcell__r   r   re   r(   rN   U   s    



rN   c                      sl  e Zd ZU dZded< dRdS fd	d
ZdTddZdU fddZdU fddZdV fddZ	dW fddZ
dU fddZdX fddZdYdd ZdZd"d#Zd[d%d&Zd\d(d)ZeZd] fd,d-Zd^d0d1Zd_d3d4Zd^d5d6Zd`d8d9Zdad;d<Zdbd=d>Zd^d?d@Zd` fdAdBZdcdDdEZdd fdFdGZdadHdIZdd fdJdKZd^dLdMZdd fdNdOZ dcdPdQZ!  Z"S )e
OrderedSet_listList[_T]rl   Nr[   Optional[Iterable[_T]]r    Nonec                   s.   |d urt || _t | j d S g | _d S r.   )unique_listrl   rc   rL   )r'   r[   re   r   r(   rC      s   

zOrderedSet.__init__OrderedSet[_T]c                 C  s&   |   }| j |_t||j |S r.   )r$   rl   copysetrL   )r'   cpr   r   r(   rr      s   zOrderedSet.copyelementr   c                   s$   || vr
| j | t | d S r.   rl   appendrc   addr'   ru   re   r   r(   rx      s   zOrderedSet.addc                   s   t  | | j| d S r.   )rc   removerl   ry   re   r   r(   rz      s   zOrderedSet.removec                   s8   z| j  }W n ty   tdd w t | |S )Npop from an empty set)rl   rI   
IndexErrorKeyErrorrc   rz   r'   r3   re   r   r(   rI      s   
zOrderedSet.popposintc                   s&   || vr| j || t | d S r.   )rl   insertrc   rx   )r'   r   ru   re   r   r(   r      s   zOrderedSet.insertc                   s(   || v r| j | t | d S d S r.   )rl   rz   rc   ry   re   r   r(   discard   s   zOrderedSet.discardc                   s   t    g | _d S r.   )rc   rE   rl   rD   re   r   r(   rE      s   

zOrderedSet.clearr,   c                 C  s
   | j | S r.   rk   r0   r   r   r(   __getitem__      
zOrderedSet.__getitem__Iterator[_T]c                 C  
   t | jS r.   )iterrl   rD   r   r   r(   __iter__   r   zOrderedSet.__iter__otherc                 C  
   |  |S r.   rX   r'   r   r   r   r(   __add__   r   zOrderedSet.__add__r6   c                 C  s   d| j j| jf S Nz%s(%r))r$   r%   rl   rD   r   r   r(   r]         zOrderedSet.__repr__	iterablesIterable[_T]c                   s8   |D ]}|D ]}|| vr| j | t | qqd S r.   rv   )r'   r   iterableere   r   r(   rL      s   zOrderedSet.updateAbstractSet[_S]OrderedSet[Union[_T, _S]]c                 C     |  | | S r.   )rL   r   r   r   r(   r`         
zOrderedSet.__ior__Iterable[_S]c                 G  s   |   }|j|  |S r.   )rr   rL   )r'   r   resultr   r   r(   rX      s   
zOrderedSet.unionc                 C  r   r.   r   r   r   r   r(   rd      r   zOrderedSet.__or__Iterable[Any]c                   s(   t    j|  |  fdd| D S )Nc                 3      | ]	}| v r|V  qd S r.   r   .0a	other_setr   r(   	<genexpr>       z*OrderedSet.intersection.<locals>.<genexpr>)rs   rL   r$   r   r   r   r(   intersection   s   
zOrderedSet.intersectionAbstractSet[object]c                 C  r   r.   )r   r   r   r   r(   __and__   r   zOrderedSet.__and__c                   sp   t |tr
| } nt |tr|}t| nt|}t|  fddD }|fdd|D  |S )Nc                 3      | ]	}| vr|V  qd S r.   r   r   r   r   r(   r     r   z2OrderedSet.symmetric_difference.<locals>.<genexpr>c                 3  r   r.   r   r   rD   r   r(   r     r   )
isinstancers   r   listr$   rL   )r'   r   
collectionr   r   )r   r'   r(   symmetric_difference   s   



zOrderedSet.symmetric_differencec                 C  s   t ttttf  | |S r.   )r   rj   r   r   r   r   r   r   r   r(   __xor__	  s   zOrderedSet.__xor__c                   s&   t  j|  |  fdd| jD S )Nc                 3  r   r.   r   r   r   r   r(   r     r   z(OrderedSet.difference.<locals>.<genexpr>)rc   
differencer$   rl   r   re   r   r(   r        zOrderedSet.differenceAbstractSet[Optional[_T]]c                 C  r   r.   )r   r   r   r   r(   __sub__  r   zOrderedSet.__sub__c                   &   t  j|   fdd jD  _d S )Nc                      g | ]}| v r|qS r   r   r   rD   r   r(   
<listcomp>      z2OrderedSet.intersection_update.<locals>.<listcomp>)rc   intersection_updaterl   r   re   rD   r(   r     r   zOrderedSet.intersection_updatec                 C  r   r.   )r   r   r   r   r(   __iand__  r   zOrderedSet.__iand__c                   sX   t |tr|nt|}t |  fdd jD  _  j fdd|D 7  _d S )Nc                   r   r   r   r   rD   r   r(   r      r   z:OrderedSet.symmetric_difference_update.<locals>.<listcomp>c                   r   r   r   r   rD   r   r(   r   !  r   )r   r   r   rc   symmetric_difference_updaterl   )r'   r   r   re   rD   r(   r     s    z&OrderedSet.symmetric_difference_updatec                 C  s    |  | tttttf  | S r.   )r   r   rj   r   r   r   r   r   r   r(   __ixor__#  s   
zOrderedSet.__ixor__c                   r   )Nc                   r   r   r   r   rD   r   r(   r   )  r   z0OrderedSet.difference_update.<locals>.<listcomp>)rc   difference_updaterl   r   re   rD   r(   r   '  r   zOrderedSet.difference_updatec                 C  r   r.   )r   r   r   r   r(   __isub__+  r   zOrderedSet.__isub__r.   )r[   rn   r    ro   )r    rq   )ru   r   r    ro   )r    r   )r   r   ru   r   r    ro   r    ro   )r,   r   r    r   )r    r   )r   r   r    rq   rh   )r   r   r    ro   )r   r   r    r   )r   r   r    r   )r   r   r    rq   )r   r   r    rq   )r   r   r    rq   )r   r   r    rq   )r   r   r    ro   )#r%   r9   r:   r;   __annotations__rC   rr   rx   rz   rI   r   r   rE   r   r   r   r]   __str__rL   r`   rX   rd   r   r   r   r   r   r   r   r   r   r   r   r   ri   r   r   re   r(   rj      s@   
 














rj   c                   @  s  e Zd ZU dZded< dZd[ddZd\ddZd]ddZd\ddZd\ddZ	d^ddZ
d_ddZd`ddZd`ddZdad d!Zd`d"d#Zd`d$d%Zdad&d'Zd`d(d)Zd`d*d+Zdbd,d-Zdcd.d/Zddd0d1Zdcd2d3Zdbd4d5Zded6d7Zddd8d9Zded:d;Zdbd<d=Zded>d?Zddd@dAZdedBdCZdbdDdEZ dedFdGZ!dddHdIZ"dedJdKZ#dfdLdMZ$e$Z%dgdOdPZ&dhdRdSZ'didUdVZ(djdXdYZ)dS )kIdentitySetzA set that considers only object id() for uniqueness.

    This strategy has edge cases for builtin types- it's possible to have
    two 'foo' strings in one of these sets, for example.  Use sparingly.

    zDict[int, Any]_membersNr   Optional[Iterable[Any]]c                 C  s   t  | _|r| | d S d S r.   )rO   r   rL   r'   r   r   r   r(   rC   :  s   zIdentitySet.__init__r3   r   r    ro   c                 C  s   || j t|< d S r.   r   idr~   r   r   r(   rx   ?  r   zIdentitySet.addboolc                 C  s   t || jv S r.   )r   r   r~   r   r   r(   __contains__B  rS   zIdentitySet.__contains__c                 C  s   | j t|= d S r.   r   r~   r   r   r(   rz   E  r+   zIdentitySet.removec                 C  s&   z|  | W d S  ty   Y d S w r.   )rz   r}   r~   r   r   r(   r   H  s
   zIdentitySet.discardc                 C  s,   z
| j  }|d W S  ty   tdw )N   r{   )r   rJ   r}   )r'   pairr   r   r(   rI   N  s   

zIdentitySet.popc                 C  s   | j   d S r.   )r   rE   rD   r   r   r(   rE   U  rS   zIdentitySet.clearr   c                 C  s   t |tr| j|jkS dS )NFr   r   r   r   r   r   r(   __eq__X     
zIdentitySet.__eq__c                 C  s   t |tr| j|jkS dS )NTr   r   r   r   r(   __ne__^  r   zIdentitySet.__ne__r   c                 C  sV   t || jr	|}n| |}t| t|krdS t|jjt| j D ]} dS dS NFTr   r$   lenr   r   r   r   keysr'   r   r   mr   r   r(   issubsetd  s   
zIdentitySet.issubsetc                 C     t |tstS | |S r.   )r   r   NotImplementedr   r   r   r   r(   __le__r     

zIdentitySet.__le__c                 C  s(   t |tstS t| t|k o| |S r.   )r   r   r   r   r   r   r   r   r(   __lt__w     
zIdentitySet.__lt__c                 C  sV   t || jr	|}n| |}t| t|k rdS t| jjt|j D ]} dS dS r   r   r   r   r   r(   
issuperset|  s   
zIdentitySet.issupersetc                 C  r   r.   )r   r   r   r   r   r   r   r(   __ge__  r   zIdentitySet.__ge__c                 C  s(   t |tstS t| t|ko| |S r.   )r   r   r   r   r   r   r   r   r(   __gt__  r   zIdentitySet.__gt__c                 C  s4   |   }| j}|j| |jdd |D  |S )Nc                 s      | ]	}t ||fV  qd S r.   r   r   objr   r   r(   r     r   z$IdentitySet.union.<locals>.<genexpr>)r$   r   rL   )r'   r   r   membersr   r   r(   rX     s
   zIdentitySet.unionc                 C  r   r.   )r   r   r   rX   r   r   r   r(   rd     r   zIdentitySet.__or__c                 C  s   | j dd |D  d S )Nc                 s  r   r.   r   r   r   r   r(   r     r   z%IdentitySet.update.<locals>.<genexpr>)r   rL   r   r   r   r(   rL     s   zIdentitySet.updatec                 C     t |tstS | | | S r.   )r   r   r   rL   r   r   r   r(   r`        

zIdentitySet.__ior__c                   L   |  | j}t|| jr|j ndd |D   fdd| j D |_|S )Nc                 S     h | ]}t |qS r   r   r   r   r   r(   	<setcomp>      z)IdentitySet.difference.<locals>.<setcomp>c                      i | ]\}}| vr||qS r   r   r   kvr   r   r(   
<dictcomp>      z*IdentitySet.difference.<locals>.<dictcomp>rA   r$   r   r   itemsr'   r   r   r   r   r(   r     s   
zIdentitySet.differencec                 C  r   r.   )r   r   r   r   r   r   r   r(   r     r   zIdentitySet.__sub__c                 C     |  |j| _d S r.   )r   r   r   r   r   r(   r     r   zIdentitySet.difference_updatec                 C  r   r.   )r   r   r   r   r   r   r   r(   r     r   zIdentitySet.__isub__c                   r   )Nc                 S  r   r   r   r   r   r   r(   r     r   z+IdentitySet.intersection.<locals>.<setcomp>c                   s   i | ]\}}| v r||qS r   r   r   r   r   r(   r     r   z,IdentitySet.intersection.<locals>.<dictcomp>r   r   r   r   r(   r     s   
zIdentitySet.intersectionc                 C  r   r.   )r   r   r   r   r   r   r   r(   r     r   zIdentitySet.__and__c                 C  r   r.   )r   r   r   r   r   r(   r     r   zIdentitySet.intersection_updatec                 C  r   r.   )r   r   r   r   r   r   r   r(   r     r   zIdentitySet.__iand__c                   sj    j}t|jr|j ndd |D   fddj D |_|jfdd  D  |S )Nc                 S  s   i | ]}t ||qS r   r   r   r   r   r(   r     s    z4IdentitySet.symmetric_difference.<locals>.<dictcomp>c                   r   r   r   r   r   r   r(   r     r   c                 3  s&    | ]\}}| j vr||fV  qd S r.   )r   r   rD   r   r(   r     s    z3IdentitySet.symmetric_difference.<locals>.<genexpr>)rA   r$   r   r   r   rL   r   r   )r   r'   r(   r     s   
z IdentitySet.symmetric_differencec                 C  r   r.   r   r   r   r   r   r   r   r(   r     r   zIdentitySet.__xor__c                 C  r   r.   )r   r   r   r   r   r(   r     r   z'IdentitySet.symmetric_difference_updatec                 C  r   r.   r   r   r   r   r(   r     r   zIdentitySet.__ixor__c                 C  s   |  | j}| j |_|S r.   )rA   r$   r   rr   )r'   r   r   r   r(   rr     s   zIdentitySet.copyr   c                 C  r   r.   )r   r   rD   r   r   r(   __len__  r   zIdentitySet.__len__Iterator[Any]c                 C  s   t | j S r.   )r   r   valuesrD   r   r   r(   r     rS   zIdentitySet.__iter__r   c                 C  s   t d)Nzset objects are unhashable)r#   rD   r   r   r(   __hash__
  s   zIdentitySet.__hash__r6   c                 C  s   dt | jt| j f S r   )typer%   r   r   r   rD   r   r   r(   r]     s   zIdentitySet.__repr__r.   )r   r   )r3   r   r    ro   )r3   r   r    r   )r    r   r   )r   r   r    r   )r   r   r    r   )r   r   r    r   )r   r   r    r   )r   r   r    ro   )r   r   r    r   )r    r   )r    r   )r    r   rM   rh   )*r%   r9   r:   __doc__r   rC   rx   r   rz   r   rI   rE   r   r   r   r   r   r   r   r   rX   rd   rL   r`   r   r   r   r   r   r   r   r   r   r   r   r   rr   __copy__r   r   r   r]   r   r   r   r(   r   0  sP   
 

































r   Nseqr   hashfuncOptional[Callable[[_T], int]]r    rm   c                   s:   t  j sfdd| D S  fdd| D S )Nc                   s    g | ]}| vr|s|qS r   r   r   x)seenseen_addr   r(   r     s     zunique_list.<locals>.<listcomp>c                   s(   g | ]} |vr |s|qS r   r   r   r   r   r   r   r(   r     s
    )rs   rx   )r   r   r   r   r(   rp     s   rp   r.   )r   r   r   r   r    rm   )"
__future__r   	itertoolsr   typingr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   util.typingr   r   r   r   r   r   r<   rN   rj   r   rp   r   r   r   r(   <module>   sB   L  c