
    [hN                       U d 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m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  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. e/            Z0d*e1d+<    e/dg          Z2d*e1d,<   dpd1Z3dqd5Z4 e#            Z5d6e1d7<    G d8 d9e&e,e-f                   Z6 ed:e$          Z7 ed;e$          Z8 G d< d=ee+                   Z9 G d> d?e9e+                   Z: G d@ dAe%e9e+                   Z;drdBZ<e=Z>e<Z? G dC dDee+                   Z@ G dE dFe$          ZA G dG dHee,e-f                   ZB G dI dJee,e-f                   ZCeDZEe=ZFe'ZG G dK dLee+                   ZHdsdOZIdrdtdSZJdudYZKdZ ZLdvd\ZM	 drdwdaZNdxddZO G de dfejP        e,e-f                   ZQ G dg dhe e.                   ZR G di dje           ZS G dk dlee+                   ZT G dm dneTe+                   ZUdo ZVdS )yzCollection classes and helpers.    )annotationsN)Any)Callable)cast)	Container)Dict)	FrozenSet)Generic)Iterable)Iterator)List)Mapping)NoReturn)Optional)overload)Sequence)Set)Tuple)TypeVar)Union)
ValuesView   )HAS_CYEXTENSION)is_non_string_iterable)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          k/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/sqlalchemy/util/_collections.pymerge_lists_w_orderingr<   L   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    r;   coerce_to_immutabledictrE      s5      	A}	%	%  Qr=   zimmutabledict[Any, Any]rC   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 rB   )r    __new__)clsrH   news      r;   rK   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    r;   copyzFacadeDict.copy   s    !0
 
 	
r=   c                0    t           t          |           ffS rB   )rG   dictrP   s    r;   
__reduce__zFacadeDict.__reduce__   s    DJJ=((r=   keyr%   valuer&   Nonec                >    t                               | ||           dS )z,insert an item into the dictionary directly.N)rT   __setitem__rQ   rV   rW   s      r;   _insert_itemzFacadeDict._insert_item   s     sE*****r=   strc                <    dt                               |           z  S )NzFacadeDict(%s))rT   __repr__rP   s    r;   r_   zFacadeDict.__repr__   s    $--"5"555r=   N)rH   r   r.   rI   )r.   r   r.   r   rV   r%   rW   r&   r.   rX   )r.   r]   )	__name__
__module____qualname____doc__rK   rR   rU   r\   r_    r=   r;   rG   rG      s~        44   
 
 
 
) ) ) )+ + + +6 6 6 6 6 6r=   rG   _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]rl   datac                >    t                               | d|           d S Nrl   object__setattr__)rQ   rn   s     r;   __init__zProperties.__init__   s     4$/////r=   r.   intc                *    t          | j                  S rB   lenrl   rP   s    r;   __len__zProperties.__len__       4:r=   Iterator[_T]c                h    t          t          | j                                                            S rB   )r2   listrl   valuesrP   s    r;   __iter__zProperties.__iter__   s&    D**,,--...r=   	List[str]c                    t          t                                d | j                                        D             z   S )Nc                ,    g | ]}t          |          S rf   )r]   ).0ks     r;   
<listcomp>z&Properties.__dir__.<locals>.<listcomp>   s    AAA!s1vvAAAr=   )dirsuperrl   keys)rQ   	__class__s    r;   __dir__zProperties.__dir__   s3    577||AAtz/@/@AAAAAr=   r9   Properties[_F]List[Union[_T, _F]]c                @    t          |           t          |          z   S rB   )r}   )rQ   r9   s     r;   __add__zProperties.__add__   s    DzzDKK''r=   rV   r]   objr#   rX   c                    || j         |<   d S rB   rk   rQ   rV   r   s      r;   rZ   zProperties.__setitem__       
3r=   c                    | j         |         S rB   rk   rQ   rV   s     r;   __getitem__zProperties.__getitem__   s    z#r=   c                    | j         |= d S rB   rk   r   s     r;   __delitem__zProperties.__delitem__       JsOOOr=   c                    || j         |<   d S rB   rk   r   s      r;   rs   zProperties.__setattr__   r   r=   Dict[str, Any]c                    d| j         iS rp   rk   rP   s    r;   __getstate__zProperties.__getstate__   s    $$r=   statec                J    t                               | d|d                    d S rp   rq   )rQ   r   s     r;   __setstate__zProperties.__setstate__   s$    4%.99999r=   c                X    	 | j         |         S # t          $ r t          |          w xY wrB   )rl   KeyErrorAttributeErrorr   s     r;   __getattr__zProperties.__getattr__   s<    	&:c?" 	& 	& 	& %%%	&s    )boolc                    || j         v S rB   rk   r   s     r;   __contains__zProperties.__contains__       dj  r=   ReadOnlyProperties[_T]c                *    t          | j                  S )z8Return an immutable proxy for this :class:`.Properties`.)ReadOnlyPropertiesrl   rP   s    r;   as_readonlyzProperties.as_readonly   s     "$*---r=   rW   c                :    | j                             |           d S rB   )rl   update)rQ   rW   s     r;   r   zProperties.update   s    
%     r=   Optional[_T]c                    d S rB   rf   r   s     r;   getzProperties.get   s    -0Sr=   defaultUnion[_DT, _T]c                    d S rB   rf   rQ   rV   r   s      r;   r   zProperties.get       HKr=   NOptional[Union[_DT, _T]]Optional[Union[_T, _DT]]c                    || v r| |         S |S rB   rf   r   s      r;   r   zProperties.get   s     $;;9Nr=   c                *    t          | j                  S rB   )r}   rl   rP   s    r;   r   zProperties.keys       DJr=   List[_T]c                N    t          | j                                                  S rB   )r}   rl   r~   rP   s    r;   r~   zProperties.values   s    DJ%%''(((r=   List[Tuple[str, _T]]c                N    t          | j                                                  S rB   )r}   rl   itemsrP   s    r;   r   zProperties.items   s    DJ$$&&'''r=   c                    || j         v S rB   rk   r   s     r;   has_keyzProperties.has_key   r   r=   c                8    | j                                          d S rB   )rl   clearrP   s    r;   r   zProperties.clear   s    
r=   )rn   rm   r.   ru   r.   r{   )r.   r   )r9   r   r.   r   )rV   r]   r   r#   r.   rX   )rV   r]   r.   r#   )rV   r]   r.   rX   )r.   r   )r   r   r.   rX   )rV   r]   r.   r   )r.   r   )rW   rm   r.   rX   )rV   r]   r.   r   )rV   r]   r   r   r.   r   rB   )rV   r]   r   r   r.   r   )r.   r   )r.   r   r.   rX   )rb   rc   rd   re   	__slots____annotations__rt   ry   r   r   r   rZ   r   r   rs   r   r   r   r   r   r   r   r   r   r~   r   r   r   __classcell__)r   s   @r;   rj   rj      s%        BBI0 0 0 0   / / / /B B B B B B( ( ( (            % % % %: : : :& & & &! ! ! !. . . .
! ! ! ! 000 X0KKK XK =A           ) ) ) )( ( ( (! ! ! !       r=   rj   c                      e Zd ZdZdZd ZdS )OrderedPropertieszUProvide a __getattr__/__setattr__ interface with an OrderedDict
    as backing store.rf   c                T    t                               | t                                 d S rB   )rj   rt   OrderedDictrP   s    r;   rt   zOrderedProperties.__init__
  s"    D+--00000r=   N)rb   rc   rd   re   r   rt   rf   r=   r;   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.rf   N)rb   rc   rd   re   r   rf   r=   r;   r   r     s        NNIIIr=   r   c                      fdt           |          D             }                                                       |           dS )zSort an OrderedDict in-place.c                $    g | ]}||         fS rf   rf   )r   r   r>   s     r;   r   z,_ordered_dictionary_sort.<locals>.<listcomp>  s!    3331a1Y333r=   )rV   N)sortedr   r   )r>   rV   r   s   `  r;   _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 )WeakSequencerf   _WeakSequence__elementsSequence[_T]c                j    t          j        |           fd| _        fd|D             | _        d S )Nc                V     |            }||j                             |            d S d S rB   )_storageremove)itemselfrefrQ   s      r;   _removez&WeakSequence.__init__.<locals>._remove&  s7    799D$$T*****  r=   c                :    g | ]}t          j        |          S rf   )weakrefref)r   r:   r   s     r;   r   z)WeakSequence.__init__.<locals>.<listcomp>,  s2     
 
 
.5GK))
 
 
r=   )r   r   r   r   )rQ   r   r   s     @r;   rt   zWeakSequence.__init__#  s]     #*+d"3"3 	+ 	+ 	+ 	+
 
 
 
 
9C
 
 
r=   c                j    | j                             t          j        || j                             d S rB   )r   r4   r   r   r   )rQ   r   s     r;   r4   zWeakSequence.append0  s,    W[t|<<=====r=   c                *    t          | j                  S rB   )rx   r   rP   s    r;   ry   zWeakSequence.__len__3  s    4=!!!r=   c                8    d d | j         D             D             S )Nc              3     K   | ]}||V  	d S rB   rf   )r   r   s     r;   	<genexpr>z(WeakSequence.__iter__.<locals>.<genexpr>7  s+       
 
sC
 
r=   c              3  *   K   | ]} |            V  d S rB   rf   )r   r   s     r;   r   z(WeakSequence.__iter__.<locals>.<genexpr>8  s(      ;;cCCEE;;;;;;r=   )r   rP   s    r;   r   zWeakSequence.__iter__6  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)rQ   indexr   s      r;   r   zWeakSequence.__getitem__;  sQ    	-&C 355L  	> 	> 	>4u<===	>s    6N)rf   )r   r   )rb   rc   rd   rt   r4   ry   r   r   rf   r=   r;   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 rB   )r   rt   r   _membersadd)rQ   r   os      r;   rt   zOrderedIdentitySet.__init__E  sZ    T"""# 	  	 	 r=   rB   )r   r   )rb   rc   rd   rt   rf   r=   r;   r   r   D  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 rB   r   )rQ   r   s     r;   rt   zPopulateDict.__init__U  s    r=   rV   r   r.   c                :    |                      |          x| |<   }|S rB   r   rQ   rV   vals      r;   __missing__zPopulateDict.__missing__X  s!    ,,s+++S	C
r=   N)r   r   rV   r   r.   r   rb   rc   rd   re   rt   r   rf   r=   r;   r   r   M  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 rB   )__func__r   __self__r   r   weakself)rQ   r   r  s      r;   rt   zWeakPopulateDict.__init__c  s)    %.!*H--r=   rV   r   r.   c                `    |                      |                                 |          x| |<   }|S rB   )r   r  r   s      r;   r   zWeakPopulateDict.__missing__h  s+    ,,t}}<<<S	C
r=   N)r   r  r   r   rf   r=   r;   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 (``==``).
    )rn   _data_appender_unique&Union[Iterable[_T], Set[_T], List[_T]]rn   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 )Nr4   r   r   zSet[_T])rn   r
  getattrr	  hasattrr   r4   r   )rQ   rn   r  s      r;   rt   zUniqueAppender.__init__  s    
 	 	<")$"4"4DT8$$ 	<"&z4"8"8"?DT5!! 	<"&y$"7"7";D	< 	<r=   r   r#   r.   rX   c                x    t          |          }|| j        vr!|                     |           d| j        |<   d S d S )NT)idr
  r	  )rQ   r   id_s      r;   r4   zUniqueAppender.append  sH    hhdl""%%% $DL #"r=   r{   c                *    t          | j                  S rB   )r2   rn   rP   s    r;   r   zUniqueAppender.__iter__  s    DIr=   rB   )rn   r  r  r  )r   r#   r.   rX   r   )	rb   rc   rd   re   r   r   rt   r4   r   rf   r=   r;   r  r  v  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,   )rx   rD   typesGeneratorTyper}   r   )r  s    r;   coerce_generator_argr    sF    
3xx1}}CFE,?@@}CF||K%%%r=   xr   Optional[List[Any]]c                z    | |S t          |           s| gS t          | t                    r| S t          |           S rB   )r   rD   r}   )r  r   s     r;   to_listr    sE    y!!$$ s
	At		 Awwr=   set_Container[Any]r   Iterable[Any]r   c                :     t           f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              3  .   K   | ]}|j         	|v V  d S rB   )__hash__)r   ir  s     r;   r   z#has_intersection.<locals>.<genexpr>  s.      99Qaj9qDy999999r=   )any)r  r   s   ` r;   has_intersectionr&    s(     9999(999999r=   c                    | t                      S t          | t                     st          t          |                     S | S rB   )r0   rD   r  r  s    r;   to_setr)    s9    yuua 71::r=   Set[Any]c                    | t                      S t          | t                     st          t          |                     S | S rB   )
column_setrD   r  r(  s    r;   to_column_setr-    s<    y||a$$ '!**%%%r=   Dict[Any, Any]_newOptional[Dict[Any, Any]]kwc                v    |                                  } |r|                     |            | j        di | | S )z5Copy the given dict and update with the given values.rf   )rR   r   )r>   r/  r1  s      r;   update_copyr3    s@    
 	
A 	AHNNrNNNHr=   Iterable[_T]r{   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)rD   r]   r  flatten_iterator)r  elems     r;   r6  r6    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_alertrl   _counter_mutexru   r:  floatr;  z.Optional[Callable[[LRUCache[_KT, _VT]], None]]r<  d         ?NOptional[Callable[..., None]]c                |    || _         || _        || _        d| _        t	          j                    | _        i | _        d S )Nr   )r:  r;  r<  r=  	threadingLockr>  rl   )rQ   r:  r;  r<  s       r;   rt   zLRUCache.__init__  s:     !"$n&&<>


r=   c                0    | xj         dz  c_         | j         S )Nr   )r=  rP   s    r;   _inc_counterzLRUCache._inc_counter  s    }r=   rV   r%   r.   Optional[_VT]c                    d S rB   rf   r   s     r;   r   zLRUCache.get
  s    .1cr=   r   Union[_VT, _T]c                    d S rB   rf   r   s      r;   r   zLRUCache.get  r   r=   Optional[Union[_VT, _T]]c                    | j                             |          }|%|                                 |d         d<   |d         S |S N   r   r   )rl   r   rG  )rQ   rV   r   r   s       r;   r   zLRUCache.get  sD     z~~c""**,,DGAJ7NNr=   r&   c                f    | j         |         }|                                 |d         d<   |d         S rN  )rl   rG  )rQ   rV   r   s      r;   r   zLRUCache.__getitem__  s/    z#&&((Q
Awr=   Iterator[_KT]c                *    t          | j                  S rB   )r2   rl   rP   s    r;   r   zLRUCache.__iter__  r   r=   c                *    t          | j                  S rB   rw   rP   s    r;   ry   zLRUCache.__len__"  rz   r=   ValuesView[_VT]c                l    t          j        d | j                                        D                       S )Nc                &    i | ]\  }}||d          S )r   rf   )r   r   r$  s      r;   
<dictcomp>z#LRUCache.values.<locals>.<dictcomp>&  s"    !I!I!Ida!QqT!I!I!Ir=   )typingr   rl   r   rP   s    r;   r~   zLRUCache.values%  s0     !I!Idj6F6F6H6H!I!I!IJJJr=   rW   rX   c                n    |||                                  gf| j        |<   |                                  d S rB   )rG  rl   _manage_sizer[   s      r;   rZ   zLRUCache.__setitem__(  s;    (9(9(;(;'<=
3r=   _LRUCache__vc                    | j         |= d S rB   rk   )rQ   r[  s     r;   r   zLRUCache.__delitem__,  r   r=   c                0    | j         | j         | j        z  z   S rB   )r:  r;  rP   s    r;   size_thresholdzLRUCache.size_threshold/  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)NFrO  T)rV   reverser   )r>  acquirer   r<  rx   r:  r;  r   rl   r~   operator
itemgetterr   release)rQ   r<  
by_counterr   s       r;   rZ  zLRUCache._manage_size3  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@  rA  N)r:  ru   r;  r?  r<  rB  )rV   r%   r.   rH  )rV   r%   r   rJ  r.   rJ  rB   )rV   r%   r   rL  r.   rL  )rV   r%   r.   r&   )r.   rQ  r   )r.   rT  ra   )r[  r%   r.   rX   )r.   r?  r   )rb   rc   rd   re   r   r   rt   rG  r   r   r   r   ry   r~   rZ   r   propertyr^  rZ  rf   r=   r;   r9  r9    sz         I MMM>>>> 48	? ? ? ? ?   111 X1KKK XK =A       
          K K K K       > > > X>" " " " " "r=   r9  c                      e Zd ZddZdS )_CreateFuncTyper.   r'   c                    d S rB   rf   rP   s    r;   __call__z_CreateFuncType.__call__L        r=   N)r.   r'   rb   rc   rd   rj  rf   r=   r;   rh  rh  K  s        $$$$$$r=   rh  c                      e Zd ZddZdS )_ScopeFuncTyper.   r   c                    d S rB   rf   rP   s    r;   rj  z_ScopeFuncType.__call__P  rk  r=   Nr`   rl  rf   r=   r;   rn  rn  O  s        """"""r=   rn  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]rs  rn  rt  r   ru  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).

        Nrr  )rQ   rs  rt  s      r;   rt   zScopedRegistry.__init__h  s     %"r=   r.   r#   c                    |                                  }	 | j        |         S # t          $ r0 | j                            ||                                           cY S w xY wrB   )rt  ru  r   
setdefaultrs  r   s     r;   rj  zScopedRegistry.__call__y  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.)rt  ru  rP   s    r;   haszScopedRegistry.has  s     ~~4=00r=   r   rX   c                >    || j         |                                 <   dS )z$Set the value for the current scope.N)ru  rt  rQ   r   s     r;   r0   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)ru  rt  r   rP   s    r;   r   zScopedRegistry.clear  sC    	dnn../// 	 	 	DD	s    
,,N)rs  rv  rt  rw  r.   r#   r.   r   r   r#   r.   rX   r   )rb   rc   rd   re   r   r   rt   rj  r|  r0   r   rf   r=   r;   rq  rq  S  s           6I####MMM   "D D D D1 1 1 1
. . . .
     r=   rq  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.

    rs  rv  c                D    || _         t          j                    | _        d S rB   )rs  rD  localru  )rQ   rs  s     r;   rt   zThreadLocalRegistry.__init__  s    $!))r=   r.   r#   c                    	 | j         j        S # t          $ r% |                                 x}| j         _        |cY S w xY wrB   )ru  rW   r   rs  )rQ   r   s     r;   rj  zThreadLocalRegistry.__call__  sO    	=&& 	 	 	(,(9(99C$-%JJJ	s    ,==r   c                ,    t          | j        d          S )NrW   )r  ru  rP   s    r;   r|  zThreadLocalRegistry.has  s    t}g...r=   r   rX   c                    || j         _        d S rB   )ru  rW   r~  s     r;   r0   zThreadLocalRegistry.set  s    !r=   c                8    	 | j         `d S # t          $ r Y d S w xY wrB   )ru  rW   r   rP   s    r;   r   zThreadLocalRegistry.clear  s7    	### 	 	 	DD	s    
N)rs  rv  r  r  r  r   )	rb   rc   rd   re   rt   rj  r|  r0   r   rf   r=   r;   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   TFrf   )sequencetargetcr   s       r;   	has_dupesr    s@     	
A  6>>FA1uutt5r=   )r+   r,   r-   r,   r.   r,   )r>   r?   r.   r@   rB   )r  r   r.   r,   )r  r   r   r  r.   r,   )r  r  r   r   r.   r   )r  r   r.   r*  )r>   r.  r/  r0  r1  r   r.   r.  )r  r4  r.   r{   )Wre   
__future__r   rb  rD  r  rX  r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   _has_cyr   r   r   r   TYPE_CHECKING_py_collectionsr   r   r   r    r!   r"   $sqlalchemy.cyextension.immutabledict"sqlalchemy.cyextension.collectionsr#   r%   r&   r'   	frozensetr)   r   r*   r<   rE   rC   rG   rg   rh   rj   r   r   r   rT   r   sort_dictionaryr   r   r   r   r0   r,  column_dictordered_column_setr  r  r  r&  r)  r-  r3  r6  MutableMappingr9  rh  rn  rq  r  r  rf   r=   r;   <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T T T T T T T Tn1 1 1 1 1
2 1 1 1    *JrN       *    8B<   D           4S>        tCH~   ( 
 " " " " "WR[ " " "J& & & &    : : : :      9=	 	 	 	 	
 
 
 
f" f" f" f" f"v$S#X. f" f" f"R% % % % %huo % % %# # # # #X # # #= = = = =WR[ = = =@    .,   <    r=   