
    
 @gN                       U d Z ddlmZ ddlmZ ddlZddlZddlZddl	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 ddlZddlmZ ddl	m Z  ddl	m!Z! e	j"        se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) n$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
"          Z, ed#e
"          Z- ed$e
"          Z. ed%d&'          Z/ e0            Z1d(e2d)<    e0dg          Z3d(e2d*<   ded/Z4dfd3Z5 e$            Z6d4e2d5<    G d6 d7e'e-e.f                   Z7 ed8e
"          Z8 ed9e
"          Z9 G d: d;ee,                   Z: G d< d=e:e,                   Z; G d> d?e&e:e,                   Z<dgd@Z=e>Z?e=Z@ G dA dBee,                   ZA G dC dDe%          ZB G dE dFee-e.f                   ZC G dG dHee-e.f                   ZDeEZFe>ZGe(ZH G dI dJee,                   ZIdhdMZJdgdidQZKdR ZLdS ZMdjdUZNdgdVZOdkdYZP G dZ d[e	jQ        e-e.f                   ZR G d\ d]e!e/                   ZS G d^ d_e!          ZT G d` daee,                   ZU G db dceUe,                   ZVdd ZWdS )lzCollection classes and helpers.    )annotationsN)Any)Callable)cast)Dict)	FrozenSet)Generic)Iterable)Iterator)List)Mapping)NoReturn)Optional)overload)Sequence)Set)Tuple)TypeVar)Union)
ValuesView   )HAS_CYEXTENSION)Literal)Protocol)immutabledict)IdentitySet)ReadOnlyContainer)ImmutableDictBase)
OrderedSet)unique_list_T)bound_KT_VT_T_coT)	covariantzFrozenSet[Any]	EMPTY_SETNONE_SETa	List[Any]breturnc                ,   t          |                               |          }g }t          |           t          |          }}	 |D ]6}||v r|                    |           ||}} n,|                    |           7|                    |           nP|S )af  merge two lists, maintaining ordering as much as possible.

    this is to reconcile vars(cls) with cls.__annotations__.

    Example::

        >>> a = ['__tablename__', 'id', 'x', 'created_at']
        >>> b = ['id', 'name', 'data', 'y', 'created_at']
        >>> merge_lists_w_ordering(a, b)
        ['__tablename__', 'id', 'name', 'data', 'y', 'x', 'created_at']

    This is not necessarily the ordering that things had on the class,
    in this case the class is::

        class User(Base):
            __tablename__ = "users"

            id: Mapped[int] = mapped_column(primary_key=True)
            name: Mapped[str]
            data: Mapped[Optional[str]]
            x = Column(Integer)
            y: Mapped[int]
            created_at: Mapped[datetime.datetime] = mapped_column()

    But things are *mostly* ordered.

    The algorithm could also be done by creating a partial ordering for
    all items in both lists and then using topological_sort(), but that
    is too much overhead.

    Background on how I came up with this is at:
    https://gist.github.com/zzzeek/89de958cf0803d148e74861bd682ebae

    )setintersectioniterdiscardappendextend)r)   r+   overlapresultcurrentotherelements          P/var/www/piapp/venv/lib/python3.11/site-packages/sqlalchemy/util/_collections.pymerge_lists_w_orderingr:   K   s    F !ff!!!$$GF!WWd1ggUG
 		 		G'!!(((!(%wMM'""""MM%   
 M    dMapping[_KT, _VT]immutabledict[_KT, _VT]c                `    | st           S t          | t                    r| S t          |           S N)
EMPTY_DICT
isinstancer   )r<   s    r9   coerce_to_immutabledictrC      s5      	A}	%	%  Qr;   zimmutabledict[Any, Any]rA   c                  :    e Zd ZdZddZddZdd	ZddZddZdS )
FacadeDictz*A dictionary that is not publicly mutable.argsr   r,   FacadeDict[Any, Any]c                .    t          j        |           }|S r@   )r   __new__)clsrF   news      r9   rI   zFacadeDict.__new__   s    ',,
r;   r   c                     t          d          )Nz\an immutabledict shouldn't need to be copied.  use dict(d) if you need a mutable dictionary.)NotImplementedErrorselfs    r9   copyzFacadeDict.copy   s    !0
 
 	
r;   c                0    t           t          |           ffS r@   )rE   dictrN   s    r9   
__reduce__zFacadeDict.__reduce__   s    DJJ=((r;   keyr#   valuer$   Nonec                >    t                               | ||           dS )z,insert an item into the dictionary directly.N)rR   __setitem__rO   rT   rU   s      r9   _insert_itemzFacadeDict._insert_item   s     sE*****r;   strc                <    dt                               |           z  S )NzFacadeDict(%s))rR   __repr__rN   s    r9   r]   zFacadeDict.__repr__   s    $--"5"555r;   N)rF   r   r,   rG   )r,   r   r,   r   rT   r#   rU   r$   r,   rV   )r,   r[   )	__name__
__module____qualname____doc__rI   rP   rS   rZ   r]    r;   r9   rE   rE      s~        44   
 
 
 
) ) ) )+ + + +6 6 6 6 6 6r;   rE   _DT_Fc                      e Zd ZU dZdZded<   d6dZd7d	Zd8dZd9 f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dAd#ZdBd%ZedCd'            ZedDd*            Z	 dEdFd.Zd9d/ZdGd1ZdHd3Zd@d4ZdId5Z xZS )J
Propertiesz8Provide a __getattr__/__setattr__ interface over a dict._dataDict[str, _T]rj   datac                >    t                               | d|           d S Nrj   object__setattr__)rO   rl   s     r9   __init__zProperties.__init__   s     4$/////r;   r,   intc                *    t          | j                  S r@   lenrj   rN   s    r9   __len__zProperties.__len__       4:r;   Iterator[_T]c                h    t          t          | j                                                            S r@   )r0   listrj   valuesrN   s    r9   __iter__zProperties.__iter__   s&    D**,,--...r;   	List[str]c                    t          t                                d | j                                        D             z   S )Nc                ,    g | ]}t          |          S rd   )r[   ).0ks     r9   
<listcomp>z&Properties.__dir__.<locals>.<listcomp>   s    AAA!s1vvAAAr;   )dirsuperrj   keys)rO   	__class__s    r9   __dir__zProperties.__dir__   s3    577||AAtz/@/@AAAAAr;   r7   Properties[_F]List[Union[_T, _F]]c                @    t          |           t          |          z   S r@   )r{   )rO   r7   s     r9   __add__zProperties.__add__   s    DzzDKK''r;   rT   r[   objr!   rV   c                    || j         |<   d S r@   ri   rO   rT   r   s      r9   rX   zProperties.__setitem__       
3r;   c                    | j         |         S r@   ri   rO   rT   s     r9   __getitem__zProperties.__getitem__   s    z#r;   c                    | j         |= d S r@   ri   r   s     r9   __delitem__zProperties.__delitem__       JsOOOr;   c                    || j         |<   d S r@   ri   r   s      r9   rq   zProperties.__setattr__   r   r;   Dict[str, Any]c                    d| j         iS rn   ri   rN   s    r9   __getstate__zProperties.__getstate__   s    $$r;   statec                J    t                               | d|d                    d S rn   ro   )rO   r   s     r9   __setstate__zProperties.__setstate__   s$    4%.99999r;   c                X    	 | j         |         S # t          $ r t          |          w xY wr@   )rj   KeyErrorAttributeErrorr   s     r9   __getattr__zProperties.__getattr__   s<    	&:c?" 	& 	& 	& %%%	&s    )boolc                    || j         v S r@   ri   r   s     r9   __contains__zProperties.__contains__       dj  r;   ReadOnlyProperties[_T]c                *    t          | j                  S )z8Return an immutable proxy for this :class:`.Properties`.)ReadOnlyPropertiesrj   rN   s    r9   as_readonlyzProperties.as_readonly   s     "$*---r;   rU   c                :    | j                             |           d S r@   )rj   update)rO   rU   s     r9   r   zProperties.update   s    
%     r;   Optional[_T]c                    d S r@   rd   r   s     r9   getzProperties.get       r;   defaultUnion[_DT, _T]c                    d S r@   rd   rO   rT   r   s      r9   r   zProperties.get   r   r;   NOptional[Union[_DT, _T]]Optional[Union[_T, _DT]]c                    || v r| |         S |S r@   rd   r   s      r9   r   zProperties.get   s     $;;9Nr;   c                *    t          | j                  S r@   )r{   rj   rN   s    r9   r   zProperties.keys       DJr;   List[_T]c                N    t          | j                                                  S r@   )r{   rj   r|   rN   s    r9   r|   zProperties.values   s    DJ%%''(((r;   List[Tuple[str, _T]]c                N    t          | j                                                  S r@   )r{   rj   itemsrN   s    r9   r   zProperties.items   s    DJ$$&&'''r;   c                    || j         v S r@   ri   r   s     r9   has_keyzProperties.has_key   r   r;   c                8    | j                                          d S r@   )rj   clearrN   s    r9   r   zProperties.clear  s    
r;   )rl   rk   r,   rs   r,   ry   )r,   r~   )r7   r   r,   r   )rT   r[   r   r!   r,   rV   )rT   r[   r,   r!   )rT   r[   r,   rV   )r,   r   )r   r   r,   rV   )rT   r[   r,   r   )r,   r   )rU   rk   r,   rV   )rT   r[   r,   r   )rT   r[   r   r   r,   r   r@   )rT   r[   r   r   r,   r   )r,   r   )r,   r   r,   rV   )r`   ra   rb   rc   	__slots____annotations__rr   rw   r}   r   r   rX   r   r   rq   r   r   r   r   r   r   r   r   r   r|   r   r   r   __classcell__)r   s   @r9   rh   rh      s7        BBI0 0 0 0   / / / /B B B B B B( ( ( (            % % % %: : : :& & & &! ! ! !. . . .
! ! ! !    X    X =A           ) ) ) )( ( ( (! ! ! !       r;   rh   c                      e Zd ZdZdZd ZdS )OrderedPropertieszUProvide a __getattr__/__setattr__ interface with an OrderedDict
    as backing store.rd   c                T    t                               | t                                 d S r@   )rh   rr   OrderedDictrN   s    r9   rr   zOrderedProperties.__init__  s"    D+--00000r;   N)r`   ra   rb   rc   r   rr   rd   r;   r9   r   r     s4          I1 1 1 1 1r;   r   c                      e Zd ZdZdZdS )r   zDProvide immutable dict/object attribute to an underlying dictionary.rd   N)r`   ra   rb   rc   r   rd   r;   r9   r   r     s        NNIIIr;   r   c                      fdt           |          D             }                                                       |           dS )zSort an OrderedDict in-place.c                $    g | ]}||         fS rd   rd   )r   r   r<   s     r9   r   z,_ordered_dictionary_sort.<locals>.<listcomp>  s!    3331a1Y333r;   )rT   N)sortedr   r   )r<   rT   r   s   `  r9   _ordered_dictionary_sortr     sK     4333qc 2 2 2333EGGIIIHHUOOOOOr;   c                  0    e Zd Zd
ddZd Zd Zd Zd Zd	S )WeakSequencerd   _WeakSequence__elementsSequence[_T]c                j    t          j        |           fd| _        fd|D             | _        d S )Nc                V     |            }||j                             |            d S d S r@   )_storageremove)itemselfrefrO   s      r9   _removez&WeakSequence.__init__.<locals>._remove'  s7    799D$$T*****  r;   c                :    g | ]}t          j        |          S rd   )weakrefref)r   r8   r   s     r9   r   z)WeakSequence.__init__.<locals>.<listcomp>-  s2     
 
 
.5GK))
 
 
r;   )r   r   r   r   )rO   r   r   s     @r9   rr   zWeakSequence.__init__$  s]     #*+d"3"3 	+ 	+ 	+ 	+
 
 
 
 
9C
 
 
r;   c                j    | j                             t          j        || j                             d S r@   )r   r2   r   r   r   )rO   r   s     r9   r2   zWeakSequence.append1  s,    W[t|<<=====r;   c                *    t          | j                  S r@   )rv   r   rN   s    r9   rw   zWeakSequence.__len__4  s    4=!!!r;   c                8    d d | j         D             D             S )Nc              3     K   | ]}||V  	d S r@   rd   )r   r   s     r9   	<genexpr>z(WeakSequence.__iter__.<locals>.<genexpr>8  s+       
 
sC
 
r;   c              3  *   K   | ]} |            V  d S r@   rd   )r   r   s     r9   r   z(WeakSequence.__iter__.<locals>.<genexpr>9  s(      ;;cCCEE;;;;;;r;   )r   rN   s    r9   r}   zWeakSequence.__iter__7  s3    
 
;;T];;;
 
 
 	
r;   c                r    	 | j         |         } |            S # t          $ r t          d|z            w xY w)NzIndex %s out of range)r   r   
IndexError)rO   indexr   s      r9   r   zWeakSequence.__getitem__<  sQ    	-&C 355L  	> 	> 	>4u<===	>s    6N)rd   )r   r   )r`   ra   rb   rr   r2   rw   r}   r   rd   r;   r9   r   r   #  si        
 
 
 
 
> > >" " "
 
 

    r;   r   c                      e Zd ZdddZdS )OrderedIdentitySetNiterableOptional[Iterable[Any]]c                    t          j        |            t                      | _        |r|D ]}|                     |           d S d S r@   )r   rr   r   _membersadd)rO   r   os      r9   rr   zOrderedIdentitySet.__init__F  sZ    T"""# 	  	 	 r;   r@   )r   r   )r`   ra   rb   rr   rd   r;   r9   r   r   E  s-              r;   r   c                  "    e Zd ZdZd
dZddZd	S )PopulateDictzA dict which populates missing values via a creation function.

    Note the creation function takes a key, unlike
    collections.defaultdict.

    creatorCallable[[_KT], _VT]c                    || _         d S r@   r   )rO   r   s     r9   rr   zPopulateDict.__init__V  s    r;   rT   r   r,   c                :    |                      |          x| |<   }|S r@   r   rO   rT   vals      r9   __missing__zPopulateDict.__missing__Y  s!    ,,s+++S	C
r;   N)r   r   rT   r   r,   r   r`   ra   rb   rc   rr   r   rd   r;   r9   r   r   N  sF                 r;   r   c                  "    e Zd ZdZd
dZddZd	S )WeakPopulateDictzaLike PopulateDict, but assumes a self + a method and does not create
    a reference cycle.

    creator_methodtypes.MethodTypec                ^    |j         | _        |j        }t          j        |          | _        d S r@   )__func__r   __self__r   r   weakself)rO   r   r  s      r9   rr   zWeakPopulateDict.__init__d  s)    %.!*H--r;   rT   r   r,   c                `    |                      |                                 |          x| |<   }|S r@   )r   r  r   s      r9   r   zWeakPopulateDict.__missing__i  s+    ,,t}}<<<S	C
r;   N)r   r   r   r   rd   r;   r9   r   r   ^  sF         
. . . .
     r;   r   c                  R    e Zd ZU dZdZded<   ded<   ded<   	 dddZddZddZd	S )UniqueAppenderzAppends items to a collection ensuring uniqueness.

    Additional appends() of the same object are ignored.  Membership is
    determined by identity (``is a``) not equality (``==``).
    )rl   _data_appender_unique&Union[Iterable[_T], Set[_T], List[_T]]rl   zCallable[[_T], None]r  zDict[int, Literal[True]]r  NviaOptional[str]c                   || _         i | _        |rt          ||          | _        d S t	          |d          rt          d|          j        | _        d S t	          |d          rt          d|          j        | _        d S d S )Nr2   r   r   zSet[_T])rl   r  getattrr  hasattrr   r2   r   )rO   rl   r
  s      r9   rr   zUniqueAppender.__init__  s    
 	 	<")$"4"4DT8$$ 	<"&z4"8"8"?DT5!! 	<"&y$"7"7";D	< 	<r;   r   r!   r,   rV   c                x    t          |          }|| j        vr!|                     |           d| j        |<   d S d S )NT)idr  r  )rO   r   id_s      r9   r2   zUniqueAppender.append  sH    hhdl""%%% $DL #"r;   ry   c                *    t          | j                  S r@   )r0   rl   rN   s    r9   r}   zUniqueAppender.__iter__  s    DIr;   r@   )rl   r	  r
  r  )r   r!   r,   rV   r   )	r`   ra   rb   rc   r   r   rr   r2   r}   rd   r;   r9   r  r  w  s           4I0000((((%%%%
 "< < < < <% % % %     r;   r  argr   c                    t          |           dk    r5t          | d         t          j                  rt	          | d                   S t          d|           S )Nr   r   r*   )rv   rB   typesGeneratorTyper{   r   )r  s    r9   coerce_generator_argr    sF    
3xx1}}CFE,?@@}CF||K%%%r;   xr   Optional[List[Any]]c                    | |S t          | t          j                  rt          | t          t          f          r| gS t          | t
                    r| S t          |           S r@   )rB   collections_abcr
   r[   bytesr{   )r  r   s     r9   to_listr    sf    ya122 j	C<7 7  s
	At		 Awwr;   c                Z    t          |                     d |D                                 S )zreturn True if any items of set\_ are present in iterable.

    Goes through special effort to ensure __hash__ is not called
    on items in iterable that don't support it.

    c                     g | ]}|j         	|S rd   )__hash__)r   is     r9   r   z$has_intersection.<locals>.<listcomp>  s    "E"E"E!*"E1"E"E"Er;   )r   r/   )set_r   s     r9   has_intersectionr#    s/     !!"E"Eh"E"E"EFFGGGr;   c                    | t                      S t          | t                     st          t          |                     S | S r@   )r.   rB   r  r  s    r9   to_setr&    s9    yuua 71::r;   Set[Any]c                    | t                      S t          | t                     st          t          |                     S | S r@   )
column_setrB   r  r%  s    r9   to_column_setr*    s<    y||a$$ '!**%%%r;   c                v    |                                  } |r|                     |            | j        di | | S )z5Copy the given dict and update with the given values.rd   )rP   r   )r<   _newkws      r9   update_copyr.    s@     	
A 	AHNNrNNNHr;   Iterable[_T]ry   c              #     K   | D ]A}t          |t                    s&t          |d          rt          |          E d{V  =|V  BdS )zGiven an iterator of which further sub-elements may also be
    iterators, flatten the sub-elements into a single iterator.

    r}   N)rB   r[   r  flatten_iterator)r  elems     r9   r1  r1    sr         $$$ 	z)B)B 	'----------JJJJ	 r;   c                      e Zd ZU dZdZded<   ded<   ded<   	 	 	 d'd(dZd Zed)d            Z	ed*d            Z		 d+d,dZ	d-dZ
d.dZd/dZd0dZd1d"Zd2d$Zed3d%            Zd4d&ZdS )5LRUCachezDictionary with 'squishy' removal of least
    recently used items.

    Note that either get() or [] should be used here, but
    generally its not safe to do an "in" check first as the dictionary
    can change subsequent to that call.

    )capacity	threshold
size_alertrj   _counter_mutexrs   r5  floatr6  z.Optional[Callable[[LRUCache[_KT, _VT]], None]]r7  d         ?NOptional[Callable[..., None]]c                |    || _         || _        || _        d| _        t	          j                    | _        i | _        d S )Nr   )r5  r6  r7  r8  	threadingLockr9  rj   )rO   r5  r6  r7  s       r9   rr   zLRUCache.__init__  s:     !"$n&&<>


r;   c                0    | xj         dz  c_         | j         S )Nr   )r8  rN   s    r9   _inc_counterzLRUCache._inc_counter  s    }r;   rT   r#   r,   Optional[_VT]c                    d S r@   rd   r   s     r9   r   zLRUCache.get  r   r;   r   Union[_VT, _T]c                    d S r@   rd   r   s      r9   r   zLRUCache.get  r   r;   Optional[Union[_VT, _T]]c                    | j                             |          }|%|                                 |d         d<   |d         S |S N   r   r   )rj   r   rB  )rO   rT   r   r   s       r9   r   zLRUCache.get  sD     z~~c""**,,DGAJ7NNr;   r$   c                f    | j         |         }|                                 |d         d<   |d         S rI  )rj   rB  )rO   rT   r   s      r9   r   zLRUCache.__getitem__  s/    z#&&((Q
Awr;   Iterator[_KT]c                *    t          | j                  S r@   )r0   rj   rN   s    r9   r}   zLRUCache.__iter__#  r   r;   c                *    t          | j                  S r@   ru   rN   s    r9   rw   zLRUCache.__len__&  rx   r;   ValuesView[_VT]c                l    t          j        d | j                                        D                       S )Nc                &    i | ]\  }}||d          S )r   rd   )r   r   r!  s      r9   
<dictcomp>z#LRUCache.values.<locals>.<dictcomp>*  s"    !I!I!Ida!QqT!I!I!Ir;   )typingr   rj   r   rN   s    r9   r|   zLRUCache.values)  s0     !I!Idj6F6F6H6H!I!I!IJJJr;   rU   rV   c                n    |||                                  gf| j        |<   |                                  d S r@   )rB  rj   _manage_sizerY   s      r9   rX   zLRUCache.__setitem__,  s;    (9(9(;(;'<=
3r;   _LRUCache__vc                    | j         |= d S r@   ri   )rO   rV  s     r9   r   zLRUCache.__delitem__0  r   r;   c                0    | j         | j         | j        z  z   S r@   )r5  r6  rN   s    r9   size_thresholdzLRUCache.size_threshold3  s    }t}t~===r;   c                   | j                             d          sd S 	 t          | j                  }t	          |           | j        | j        | j        z  z   k    r|rd}|                     |            t          | j        	                                t          j        d          d          }|| j        d          D ]!}	 | j        |d         = # t          $ r Y w xY wt	          |           | j        | j        | j        z  z   k    | j                                          d S # | j                                          w xY w)NFrJ  T)rT   reverser   )r9  acquirer   r7  rv   r5  r6  r   rj   r|   operator
itemgetterr   release)rO   r7  
by_counterr   s       r9   rU  zLRUCache._manage_size7  sT   {""5)) 	F	"do..Jd))dmdmdn.LLLL *!&JOOD)))#J%%'' +A..   

 't}7 ! !D! JtAw//# ! ! ! ! d))dmdmdn.LLLL  K!!!!!DK!!!!s0   B!D"  CD" 
CD" C+D" "D=)r;  r<  N)r5  rs   r6  r:  r7  r=  )rT   r#   r,   rC  )rT   r#   r   rE  r,   rE  r@   )rT   r#   r   rG  r,   rG  )rT   r#   r,   r$   )r,   rL  r   )r,   rO  r_   )rV  r#   r,   rV   )r,   r:  r   )r`   ra   rb   rc   r   r   rr   rB  r   r   r   r}   rw   r|   rX   r   propertyrY  rU  rd   r;   r9   r4  r4    s         I MMM>>>> 48	? ? ? ? ?      X    X =A       
          K K K K       > > > X>" " " " " "r;   r4  c                      e Zd ZddZdS )_CreateFuncTyper,   r%   c                    d S r@   rd   rN   s    r9   __call__z_CreateFuncType.__call__P      r;   N)r,   r%   r`   ra   rb   re  rd   r;   r9   rc  rc  O  (             r;   rc  c                      e Zd ZddZdS )_ScopeFuncTyper,   r   c                    d S r@   rd   rN   s    r9   re  z_ScopeFuncType.__call__U  rf  r;   Nr^   rg  rd   r;   r9   rj  rj  T  rh  r;   rj  c                  ^    e Zd ZU dZdZded<   ded<   ded<   ddZddZddZddZ	ddZ
dS )ScopedRegistrya  A Registry that can store one or multiple instances of a single
    class on the basis of a "scope" function.

    The object implements ``__call__`` as the "getter", so by
    calling ``myregistry()`` the contained object is returned
    for the current scope.

    :param createfunc:
      a callable that returns a new object to be placed in the registry

    :param scopefunc:
      a callable that will return a key to store/retrieve an object.
    
createfunc	scopefuncregistryz_CreateFuncType[_T]ro  rj  rp  r   rq  Callable[[], _T]Callable[[], Any]c                0    || _         || _        i | _        dS )aV  Construct a new :class:`.ScopedRegistry`.

        :param createfunc:  A creation function that will generate
          a new value for the current scope, if none is present.

        :param scopefunc:  A function that returns a hashable
          token representing the current scope (such as, current
          thread identifier).

        Nrn  )rO   ro  rp  s      r9   rr   zScopedRegistry.__init__n  s     %"r;   r,   r!   c                    |                                  }	 | j        |         S # t          $ r0 | j                            ||                                           cY S w xY wr@   )rp  rq  r   
setdefaultro  r   s     r9   re  zScopedRegistry.__call__  sk    nn	D=%% 	D 	D 	D=++C1B1BCCCCC	Ds   # 7AAr   c                8    |                                  | j        v S )z9Return True if an object is present in the current scope.)rp  rq  rN   s    r9   haszScopedRegistry.has  s     ~~4=00r;   r   rV   c                >    || j         |                                 <   dS )z$Set the value for the current scope.N)rq  rp  rO   r   s     r9   r.   zScopedRegistry.set  s      +.dnn&&'''r;   c                ^    	 | j         |                                 = dS # t          $ r Y dS w xY w)z Clear the current scope, if any.N)rq  rp  r   rN   s    r9   r   zScopedRegistry.clear  sC    	dnn../// 	 	 	DD	s    
,,N)ro  rr  rp  rs  r,   r!   r,   r   r   r!   r,   rV   r   )r`   ra   rb   rc   r   r   rr   re  rx  r.   r   rd   r;   r9   rm  rm  Y  s           6I####MMM   "D D D D1 1 1 1
. . . .
     r;   rm  c                  :    e Zd ZdZddZddZdd	ZddZddZdS )ThreadLocalRegistryz\A :class:`.ScopedRegistry` that uses a ``threading.local()``
    variable for storage.

    ro  rr  c                D    || _         t          j                    | _        d S r@   )ro  r?  localrq  )rO   ro  s     r9   rr   zThreadLocalRegistry.__init__  s    $!))r;   r,   r!   c                    	 | j         j        S # t          $ r% |                                 x}| j         _        |cY S w xY wr@   )rq  rU   r   ro  )rO   r   s     r9   re  zThreadLocalRegistry.__call__  sO    	=&& 	 	 	(,(9(99C$-%JJJ	s    ,==r   c                ,    t          | j        d          S )NrU   )r  rq  rN   s    r9   rx  zThreadLocalRegistry.has  s    t}g...r;   r   rV   c                    || j         _        d S r@   )rq  rU   rz  s     r9   r.   zThreadLocalRegistry.set  s    !r;   c                8    	 | j         `d S # t          $ r Y d S w xY wr@   )rq  rU   r   rN   s    r9   r   zThreadLocalRegistry.clear  s7    	### 	 	 	DD	s    
N)ro  rr  r|  r}  r~  r   )	r`   ra   rb   rc   rr   re  rx  r.   r   rd   r;   r9   r  r    s         
* * * *   / / / /" " " "     r;   r  c                8    d}| D ]}||u r|dz  }|dk    r dS dS )zrGiven a sequence and search object, return True if there's more
    than one, False if zero or one of them.


    r   r   TFrd   )sequencetargetcr   s       r9   	has_dupesr    s@     	
A  6>>FA1uutt5r;   )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'  )r  r/  r,   ry   )Xrc   
__future__r   collections.abcabcr  r]  r?  r  rS  r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   _has_cyr   r   r   TYPE_CHECKING_py_collectionsr   r   r   r   r   r    $sqlalchemy.cyextension.immutabledict"sqlalchemy.cyextension.collectionsr!   r#   r$   r%   	frozensetr'   r   r(   r:   rC   rA   rE   re   rf   rh   r   r   r   rR   r   sort_dictionaryr   r   r   r   r.   r)  column_dictordered_column_setr  r  r  r#  r&  r*  r.  r1  MutableMappingr4  rc  rj  rm  r  r  rd   r;   r9   <module>r     s   & % % " " " " " " ) ) ) ) ) )                                                                                                                           $ $ $ $ $ $            	  ??????;;;;;;GGGGGGGGGGGG999999;;;;;;;                NMMMMMKKKKKK     
 WTge3ge34(((%IKK	 ' ' ' '$9dV,, , , , ,5 5 5 5p        '4moo
 5 5 5 56 6 6 6 6"38, 6 6 60 ge3WTV V V V V V V Vr1 1 1 1 1
2 1 1 1    *JrN       *    8B<   D           4S>        tCH~   ( 
 " " " " "WR[ " " "J& & & &
 
 
 
 
H H H        
 
 
 
h" h" h" h" h"v$S#X. h" h" h"V    huo   
    X   
= = = = =WR[ = = =@    .,   <    r;   