Ë
    V.je  ã                  ó  — d 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	 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ef   ¬«      Z G d„ de«      Z G d„ de«      Z G d„ d«      Zy)z9State tracking utilities used by :class:`_orm.Session`.

é    )ÚannotationsN)ÚEnum)ÚAny)ÚCallable)Úcast)ÚIterator)ÚNoReturn)ÚOptional)ÚTuple)ÚTypeVar)ÚUnioné   )Úexc)Úutil)ÚLiteralÚ_F.)Úboundc                  ó   — e Zd Zy)Ú_StateChangeStateN)Ú__name__Ú
__module__Ú__qualname__© ó    ú^C:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\sqlalchemy/orm/state_changes.pyr   r   !   s   „ Ør   r   c                  ó   — e Zd ZdZdZdZy)Ú_StateChangeStatesé   r   é   N)r   r   r   ÚANYÚ	NO_CHANGEÚCHANGE_IN_PROGRESSr   r   r   r   r   %   s   „ Ø
€CØ€IØÑr   r   c                  ó¼   — e Zd ZU dZej
                  Zded<   ej                  Z	ded<   dZ
ded<   	 	 	 	 	 	 dd„Ze	 	 	 	 	 	 dd	„«       Zej                  dd
„«       Zy)Ú_StateChangea!  Supplies state assertion decorators.

    The current use case is for the :class:`_orm.SessionTransaction` class. The
    :class:`_StateChange` class itself is agnostic of the
    :class:`_orm.SessionTransaction` class so could in theory be generalized
    for other systems as well.

    r   Ú_next_stateÚ_stateNzOptional[Callable[..., Any]]Ú_current_fnc                ó<   — t        j                  d|› d|›�d¬«      ‚)NzCan't run operation 'z()' when Session is in state Úisce©Úcode)Úsa_excÚIllegalStateChangeError)ÚselfÚoperation_nameÚstates      r   Ú_raise_for_prerequisite_statez*_StateChange._raise_for_prerequisite_state9   s1   € ô ×,Ñ,Ø# NÐ#3ð 4Ø ˜)ð%àô
ð 	
r   c                ó¸   ‡‡‡‡— |sJ d«       ‚|t         j                  uŠt        d|«      Š‰t         j                  uŠt        j
                  dˆˆˆˆfd„«       }|S )a¼  Method decorator declaring valid states.

        :param prerequisite_states: sequence of acceptable prerequisite
         states.   Can be the single constant _State.ANY to indicate no
         prerequisite state

        :param moves_to: the expected state at the end of the method, assuming
         no exceptions raised.   Can be the constant _State.NO_CHANGE to
         indicate state should not change at the end of the method.

        zno prequisite states sentzTuple[_StateChangeState, ...]c                óÞ  •— |j                   }‰
r |‰vr|j                  | j                  |«       |j                  }|j                  }‰	r‰n|}|t
        j                  urˆ‰	r†||ur‚|rV|t
        j                  t
        j                  fv r4t        j                  d| j                  › d|j                  › d‰›�d¬«      ‚t        j                  d| j                  › d‰›d|›�d¬«      ‚| |_        t
        j                  |_        	  | |g|¢­i |¤Ž}|j                   |u r|||_        ||_        S |j                   |u r(t        j                  d| j                  › d	‰›d
�d¬«      ‚|r>t        j                  d|j                  › d| j                  › d|j                   ›�d¬«      ‚t        j                  d| j                  › d|j                   ›�d¬«      ‚#  ‚ xY w# ||_        ||_        w xY w)NzMethod 'z"()' can't be called here; method 'zN()' is already in progress and this would cause an unexpected state change to r)   r*   zCant run operation 'z()' here; will move to state z where we are expecting z()' failed to change state to z as expectedzWhile method 'z()' was running, method 'z)()' caused an unexpected state change to )r&   r1   r   r%   r'   r   r    r!   r"   r,   r-   )Úfnr.   ÚargÚkwÚcurrent_stateÚ
next_stateÚexisting_fnÚexpect_stateÚ	ret_valueÚexpect_state_changeÚhas_prerequisite_statesÚmoves_toÚprerequisite_state_collections            €€€€r   Ú_goz(_StateChange.declare_states.<locals>._go_   sB  ø€ à ŸK™KˆMñ (Ø!Ð)FÑFà×2Ñ2°2·;±;ÀÔNà×)Ñ)ˆJØ×*Ñ*ˆKÙ':™8ÀˆLð Ô"4×"8Ñ"8Ñ8á'à lÑ2á :Ü&×0Ñ0Ü&×9Ñ9ð2ñ $ô !×8Ñ8Ø" 2§;¡; -ð 0#Ø#.×#7Ñ#7Ð"8ð 9+à+3¨,ð8ð $ôð ô !×8Ñ8Ø.¨r¯{©{¨mð <.Ø.6¨\ð :%Ø%/ Nð4ð $ô	ð ð  "ˆDÔÜ1×DÑDˆDÔð!/Ù˜tÐ0 cÒ0¨RÑ0�	ð —;‘; ,Ñ.Ø$ð4 $.�Ô Ø#.�Õ ð3 —;‘; -Ñ/Ü ×8Ñ8Ø" 2§;¡; -ð 0à&˜\¨ð7ð $ô	ð ñ !Ü ×8Ñ8Ø(¨×)=Ñ)=Ð(>ð ?#à#%§;¡; -ð 0+à+/¯;©;¨/ð	;ð
 $ôð ô !×8Ñ8Ø" 2§;¡; -ð 0+Ø+/¯;©;¨/ð;à#ôð øð/Øûð: $.�Ô Ø#.�Õ ús%   ÄG ÄG Ä/B'G ÇGÇG ÇG,)
r4   r   r.   r   r5   r   r6   r   Úreturnr   )r   r    r   r!   r   Ú	decorator)ÚclsÚprerequisite_statesr>   r@   r<   r=   r?   s     ` @@@r   Údeclare_statesz_StateChange.declare_statesB   so   û€ ñ& #Ð?Ð$?Ó?Ð"àÔ'9×'=Ñ'=Ð=ð 	 ô )-Ø+Ð-@ó)
Ð%ð 'Ô.@×.JÑ.JÐJÐä	�‰÷K	/ó 
ðK	/ðZ ˆ
r   c              #  ó:  K  — | j                   t        j                  u sJ d«       ‚|| _         	 d–— | j                  |ur$t	        j
                  d| j                  ›�d¬«      ‚	 t        j                  | _         y#  ‚ xY w# t        j                  | _         w xY w­w)zxcalled within a method that changes states.

        method must also use the ``@declare_states()`` decorator.

        zAUnexpected call to _expect_state outside of state-changing methodNzUnexpected state change to r)   r*   )r%   r   r"   r&   r,   r-   )r.   Úexpecteds     r   Ú_expect_statez_StateChange._expect_state¯   s¢   è ø€ ð ×ÑÔ#5×#HÑ#HÑHð 	
ð$ó	
ÐHð
 $ˆÔð
	EÛð �{‰{ (Ñ*Ü×4Ñ4Ø1°$·+±+°ÐAÈôð ð +ô
  2×DÑDˆDÕøð	Øûô  2×DÑDˆDÕüs-   ‚+B®A; ²2B Á%BÁ;A>Á>B ÂBÂB)r/   Ústrr0   r   rA   r	   )rD   zEUnion[Literal[_StateChangeStates.ANY], Tuple[_StateChangeState, ...]]r>   r   rA   zCallable[[_F], _F])rG   r   rA   zIterator[Any])r   r   r   Ú__doc__r   r    r%   Ú__annotations__r!   r&   r'   r1   ÚclassmethodrE   Ú
contextlibÚcontextmanagerrH   r   r   r   r$   r$   +   s§   … ñð &8×%;Ñ%;€KÐ"Ó;Ø 2× <Ñ <€FÐÓ<Ø04€KÐ-Ó4ð
Ø!ð
Ø*;ð
à	ó
ð ðjð
ðjð
 $ðjð 
òjó ðjðX ×ÑòEó ñEr   r$   )rJ   Ú
__future__r   rM   Úenumr   Útypingr   r   r   r   r	   r
   r   r   r   Ú r   r,   r   Úutil.typingr   r   r   r   r$   r   r   r   Ú<module>rT      su   ðñõ #ã Ý Ý Ý Ý Ý Ý Ý Ý Ý Ý å Ý Ý !áˆT˜ # s (Ñ+Ô,€ô	˜ô 	ôÐ*ô ÷[Eò [Er   