
    +h                          d dl mZ d dl mZ d dlmZ d dlmZ d ZdZ ej                         Zd Zd Z	d	 Z
 G d
 de      Zy)   )exc)util)collections_abc)immutabledictc                 8     t         j                   fd       }|S )zDecorator, memoize a function in a connection.info stash.

    Only applicable to functions which take no arguments other than a
    connection.  The memo will be stored in ``connection.info[key]``.
    c                     |j                         }	 |j                     S # t        $ r  | ||      x|j                  <   }|cY S w xY wN)connectinfoKeyError)fnself
connectionvalkeys       I/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/engine/util.py	decoratedz%connection_memoize.<locals>.decorated   sS    '')
	??3'' 	)+D*)==JOOC 3J	s   " #AA)r   	decorator)r   r   s   ` r   connection_memoizer      s#     
^^       c                 |   |s|r| j                          |gS g S t        |      dk(  rc|d   }t        |t        t        f      r%|rt        |d   d      rt        |d   d      s|S |gS t        |d      r|gS | j                          |ggS | j                          t        |d   d      rt        |d   d      s|S |gS )a  Given arguments from the calling form \*multiparams, \**params,
    return a list of bind parameter structures, usually a list of
    dictionaries.

    In the case of 'raw' execution which accepts positional parameters,
    it may be a list of tuples or lists.

           __iter__stripkeys)_warn_for_legacy_exec_formatlen
isinstancelisttuplehasattrr   multiparamsparamszeros       r   _distill_paramsr(   %   s     3358OI	[	Q	1~dT5M*47J/Q1  vT6"6M335F8O//1;q>:.wNG8
 = r   c                    |s|r|gS g S t        |      dk(  rS|d   }t        |t        t        f      r%|rt	        |d   d      rt	        |d   d      s|S |gS t	        |d      r|gS |ggS t	        |d   d      rt	        |d   d      s|S |gS )z_distill_params without any warnings.  more appropriate for
    "cursor" params that can include tuple arguments, lists of tuples,
    etc.

    r   r   r   r   r   )r   r    r!   r"   r#   r$   s       r   _distill_cursor_paramsr*   X   s     8OI	[	Q	1~dT5M*47J/Q1  vT6"6M F8O;q>:.wNG8
 = r   c                 j   | t         t        fS t        | t              rC| r8t        | d   t        j
                  t        f      st        j                  d      | ft        fS t        | t        t        t        f      st        | t        j
                        r	| ft        fS t        j                  d      )Nr   z9List argument must consist only of tuples or dictionariesz+mapping or sequence expected for parameters)	_no_tuple_no_kwr    r!   r   Mappingr"   r   ArgumentErrordictr   )r&   s    r   _distill_params_20r1      s    ~&  	FD	!*1I//7
 ##K  y&  		m$

 
FO33	4y&   MNNr   c                   H    e Zd ZdZdZd Zd Zd Zd Ze	d        Z
d Zd	 Zy)
TransactionalContextzApply Python context manager behavior to transaction objects.

    Performs validation to ensure the subject of the transaction is not
    used if the transaction were ended prematurely.

    Nc                     t               r	   NotImplementedErrorr   s    r   _transaction_is_activez+TransactionalContext._transaction_is_active       !##r   c                     t               r	   r5   r7   s    r   _transaction_is_closedz+TransactionalContext._transaction_is_closed   r9   r   c                     t               )a  indicates the object is in a state that is known to be acceptable
        for rollback() to be called.

        This does not necessarily mean rollback() will succeed or not raise
        an error, just that there is currently no state detected that indicates
        rollback() would fail or emit warnings.

        It also does not mean that there's a transaction in progress, as
        it is usually safe to call rollback() even if no transaction is
        present.

        .. versionadded:: 1.4.28

        r5   r7   s    r   _rollback_can_be_calledz,TransactionalContext._rollback_can_be_called   s     "##r   c                     t               r	   r5   r7   s    r   _get_subjectz!TransactionalContext._get_subject   r9   r   c                 l    |j                   }|r&|j                         st        j                  d      y y )NzCan't operate on closed transaction inside context manager.  Please complete the context manager before emitting further commands.)_trans_context_managerr8   r   InvalidRequestError)clssubjecttrans_contexts      r   _trans_ctx_checkz%TransactionalContext._trans_ctx_check   s>    66 779--8  : r   c                 h    | j                         }|j                  }|| _        || _        | |_        | S r	   )r?   rA   _outer_trans_ctx_trans_subject)r   rD   rE   s      r   	__enter__zTransactionalContext.__enter__   s:    ##%  66 -%)-&r   c                    | j                   }|d u xs |j                  | u}|C| j                         r3	 | j                          |s| j                  |_        d x| _         | _        y 	 | j                         s!| j                         s1| j                          n | j                         r| j                          |s| j                  |_        d x| _         | _        y #  t	        j
                         5  | j                         r| j                          d d d        n# 1 sw Y   nxY wY xY w# |s| j                  |_        d x| _         | _        w xY w# |s| j                  |_        d x| _         | _        w xY wr	   )rI   rA   r8   commitr   safe_reraiser=   rollbackrH   r;   close)r   type_value	tracebackrD   out_of_band_exits         r   __exit__zTransactionalContext.__exit__   sQ   %% tOIw==TI 	 =T88:	C (595J5JG2>BB#d&;
C224668

335'595J5JG2>BB#d&;'(&&( (335( ( ( (595J5JG2>BB#d&; (595J5JG2>BB#d&;s<   C 'AE D(0!D	D(D#	D(&D+ +#E#E4)__name__
__module____qualname____doc__rI   r8   r;   r=   r?   classmethodrF   rJ   rT   r   r   r   r3   r3      sA     N$$$"$  
$Cr   r3   N) r   r   r   r   r   r,   r-   r(   r*   r1   objectr3   r   r   r   <module>r\      sQ      "  & 					0!f+!\O0_C6 _Cr   