
    [h#                     6   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 ej        rd
dlmZ d
dlmZ eeee         eedef                  f         Z	 d.d/dZd0d"Zd1d%Zd2d(Zd3d)Zd4d,Zd5d-ZdS )6zhRoutines to handle adaption of legacy call signatures,
generation of deprecation notes and docstrings.

    )annotationsN)Any)Callable)List)Optional)Tuple)Type   )_ET)_ListenerFnType   )util)FullArgSpec)_ClsLevelDispatch)_HasEventsDispatch.sincestrargnames	List[str]	converterOptional[Callable[..., Any]]return2Callable[[Callable[..., Any]], Callable[..., Any]]c                     d fd}|S )a_  legacy sig decorator


    :param since: string version for deprecation warning
    :param argnames: list of strings, which is *all* arguments that the legacy
     version accepted, including arguments that are still there
    :param converter: lambda that will accept tuple of this full arg signature
     and return tuple of new arg signature.

    fnCallable[..., Any]r   c                p    t          | d          sg | _        | j                            f           | S )N_legacy_signatures)hasattrr   append)r   r   r   r   s    f/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/sqlalchemy/event/legacy.pylegz_legacy_signature.<locals>.leg3   sA    r/00 	'$&B!
$$eXy%ABBB	    )r   r   r   r    )r   r   r   r"   s   ``` r!   _legacy_signaturer%   #   s4             Jr#   dispatch_collection_ClsLevelDispatch[_ET]r   r   argspecr   c           
        	  j         D ]\  d         dk    rddd         ndt                    t          |j                  k    rzt          |j                  u rdd j        dd                     j                  rd	nd
d}d j        d j        dd|d		rJ d	fd}nd 	fd}|c S S )Nz**kwTr   Fzdef (, , **kw )z The argument signature for the ".z+" event listener has changed as of version zl, and conversion for the old argument signature will be removed in a future release.  The new signature is ""argsr   kwr   c                 H    t          j                   J   |   S )Nversion)r   warn_deprecated)r2   r3   convr   r   warning_txts     r!   wrap_legz%_wrap_fn_for_legacy.<locals>.wrap_leg`   s8    (eDDDD+++2ttT{++r#   c                     t          j        	           t          t          j        |                     fdD             }r |i |S  | S )Nr5   c                     g | ]
}|         S r$   r$   ).0nameargdicts     r!   
<listcomp>z9_wrap_fn_for_legacy.<locals>.wrap_leg.<locals>.<listcomp>j   s    %I%I%Igdm%I%I%Ir#   )r   r7   dictzip	arg_names)
r2   r3   args_from_dictr?   r   r&   r   has_kwr   r9   s
      @r!   r:   z%_wrap_fn_for_legacy.<locals>.wrap_legg   sx    (eDDDD"3':'Dd#K#KLLG%I%I%I%I%I%I%IN 3!r>8R888!r>22r#   )r2   r   r3   r   r   r   )	legacy_signatureslenr2   boolvarkwr>   joinrC   clsname)
r&   r   r(   formatted_defr:   r   r8   rE   r   r9   s
   ``   @@@@@r!   _wrap_fn_for_legacyrM   <   s   
 "5!F 1 1xB<6!!F"~HHFx==C----&DM=
 =
 3
 3
 3
 $(((		-7888"***MM (///',,,EE!MM	  !!!!, , , , , , , , , ,3 3 3 3 3 3 3 3 3 3 3 OOO	r#   textindentc                l    d                     fd|                     d          D                       S )N
c              3  "   K   | ]	}|z   V  
d S Nr$   )r=   linerO   s     r!   	<genexpr>z_indent.<locals>.<genexpr>v   s'      @@tVd]@@@@@@r#   )rJ   split)rN   rO   s    `r!   _indentrW   u   s6    99@@@@tzz$/?/?@@@@@@r#   sample_targetr   c                @   t          d                    d | j        dd         D                       d          }| j        rt	          d | j        D                       }nd }d}||rd|z  nd	|j        | j        rd
nd	d                    | j                  ||dz  }|S )NrQ   c              3  $   K   | ]}d d|iz  V  dS )z%(arg)s = kw['%(arg)s']argNr$   )r=   r[   s     r!   rU   z+_standard_listen_example.<locals>.<genexpr>   s?       
 
 &4
 
 
 
 
 
r#   r   r   z    c              3  "   K   | ]
\  }}}|V  d S rS   r$   )r=   r   r2   r8   s       r!   rU   z+_standard_listen_example.<locals>.<genexpr>   s<       
 
!tT 
 
 
 
 
 
r#   zfrom sqlalchemy import event


@event.listens_for(%(sample_target)s, '%(event_name)s')
def receive_%(event_name)s(%(named_event_arguments)s%(has_kw_arguments)s):
    "listen for the '%(event_name)s' event"

    # ... (event handling logic) ...
z (arguments as of %s)r.   r-   r,   )current_since
event_namehas_kw_argumentsnamed_event_argumentsexample_kw_argrX   )rW   rJ   rC   rF   max__name__rE   )r&   rX   r   ra   r]   rN   s         r!   _standard_listen_examplerd   y   s    
 		 
 
*4QqS9
 
 
 	
 	
 	 N ,  
 
%8%J
 
 
 
 

 	3 	 	7DL#m33"k(;(BJHH!%+>+H!I!I(&	 	 	D Kr#   c           	         d}| j         D ]5\  }}}|d||j        | j        rdndd                    |          |dz  z  }6|S )Nr.   a&  
# DEPRECATED calling style (pre-%(since)s, will be removed in a future release)
@event.listens_for(%(sample_target)s, '%(event_name)s')
def receive_%(event_name)s(%(named_event_arguments)s%(has_kw_arguments)s):
    "listen for the '%(event_name)s' event"

    # ... (event handling logic) ...
z **kwr,   )r   r^   r_   r`   rX   )rF   rc   rE   rJ   )r&   rX   r   rN   r   r2   r8   s          r!   _legacy_listen_examplesrf      sr    
 D0B 
 
tT7  k29AGGr)-4!. 	
$ Kr#   parent_dispatch_clsType[_HasEventsDispatch[_ET]]c                     j         d         \  }}}d| j        j        d                     fdj        D                       j        rdnddz  S )Nr   a=  
.. versionchanged:: %(since)s
    The :meth:`.%(clsname)s.%(event_name)s` event now accepts the 
    arguments %(named_event_arguments)s%(has_kw_arguments)s.
    Support for listener functions which accept the previous 
    argument signature(s) listed above as "deprecated" will be 
    removed in a future release.r,   c              3  >   K   | ]}d j         j        |dz  V  dS )z6:paramref:`.%(clsname)s.%(event_name)s.%(param_name)s`)rK   r^   
param_nameN)rc   r>   )r=   rk   r&   rg   s     r!   rU   z-_version_signature_changes.<locals>.<genexpr>   sX       / /  I2;"5":", / / / / / /r#   r-   r.   )r   rK   r^   r`   r_   )rF   rc   r>   rJ   rC   rE   )rg   r&   r   r2   r8   s   ``   r!   _version_signature_changesrl      s     ,=a@E4	+ *3-2%)YY / / / / / #6"?/ / / & & -@,F NB
 
	
r#   c                   d}t          |dd          }|t          t          | ||          d          z   }| j        r5|t          t	          | ||          d          z  }|t          ||           z  }t          j        |j        |d          S )Nz@.. container:: event_signatures

     Example argument forms::

_target_class_docobjz        r
   )	getattrrW   rd   rF   rf   rl   r   inject_docstring_text__doc__)r&   rg   r   headerrX   rN   s         r!   _augment_fn_docsrt      s    	  /1DeLLMG !4mRHH  D , 
#$7KK
 
 	

 	*!4
 
 	
 %bj$:::r#   rS   )r   r   r   r   r   r   r   r   )r&   r'   r   r   r(   r   r   r   )rN   r   rO   r   r   r   )r&   r'   rX   r   r   r   r   r   )r&   r'   rX   r   r   r   r   r   )rg   rh   r&   r'   r   r   )r&   r'   rg   rh   r   r   r   r   )rr   
__future__r   typingr   r   r   r   r   r	   registryr   r   r.   r   util.compatr   TYPE_CHECKINGattrr   baser   r   _LegacySignatureTyper%   rM   rW   rd   rf   rl   rt   r$   r#   r!   <module>r}      s    # " " " " "                                            % % % % % %       % % % % % %	 )''''''(((((( S$s)XhsCx6H-IIJ  /3    26 6 6 6rA A A A& & & &R   8   <; ; ; ; ; ;r#   