
    +hk5                        d 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Zda ej                  dd      j!                         dv rdZej"                  rdan% ej                  dd      j!                         dv rdad dZd Zd!dZd!dZd!dZd"dZ	 d#dZ	 	 	 	 d$dZd Zd%dZd Zd Z	 d dZ	 d&dZy)'zSHelpers related to deprecation of functions, methods, classes, other
functionality.    N   )compat)_hash_limit_string)_warnings_warn)	decorator)inject_docstring_text)inject_param_text   )excFSQLALCHEMY_WARN_20false)trueyes1TSQLALCHEMY_SILENCE_UBER_WARNINGc                     t        |t        j                        rt        st        st        ||       y  || |      }||_        t        ||dz          y )Ncoder   
stacklevel)
issubclassr   Base20DeprecationWarningr   SILENCE_UBER_WARNING_emit_uber_warningdeprecated_sincer   )msgversiontype_r   r   warns         O/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/util/deprecations.py_warn_with_versionr!   )   sG    5#667"#uj14 D#D4JN3    c                     t         ry da t        j                  }t        |d      xr4 |j	                         xr" t
        j                  j                  d      dk7  }d}|r|dddd	d
dz  }n|ddddddz  } | |      }t        ||dz          y )NTisattyTERMdumba  %(red)sDeprecated API features detected! These feature(s) are not compatible with SQLAlchemy 2.0. %(green)sTo prevent incompatible upgrades prior to updating applications, ensure requirements files are pinned to "sqlalchemy<2.0". %(cyan)sSet environment variable SQLALCHEMY_WARN_20=1 to show all deprecation warnings.  Set environment variable SQLALCHEMY_SILENCE_UBER_WARNING=1 to silence this message.%(nocolor)sz[31mz[36mz[32mz[35mz[0m)redcyangreenmagentanocolor r   r   )	r   sysstderrhasattrr$   osenvirongetr   )r   r   file_	use_colorr   r   s         r    r   r   9   s     JJE 	x  	-LLN	-JJNN6"f, 	P  ! 
 
 
 
 :D4JN3r"   c                 @    t        | |t        j                  ||       y Nr   )r!   r   SADeprecationWarning)r   r   r   r   s       r    warn_deprecatedr8   l   s    Wc..
r"   c                 ^    |rt        | d|      } t        | |t        j                  ||       y)zhIssue a deprecation warning with a parameterized string,
    limiting the number of registrations.

    
   r   N)r   r!   r   r7   )r   argsr   r   r   s        r    warn_deprecated_limitedr<   r   s.    
  b$/Wc..
r"   c                 p    t        | t        j                  j                  t        j                  ||       y r6   )r!   r   RemovedIn20Warningr   )r   r   r   s      r    warn_deprecated_20r?   ~   s+    //r"   c                 6     d dxs d fd}|S )N.. deprecated::  r,   c           	      Z    t        | t        j                  t              z        S )Nfunc)_decorate_cls_with_warningr   r7   dict)clsconstructorheadermessager   s    r    decoratez deprecated_cls.<locals>.decorate   s2    )$$d,,
 	
r"    )r   rK   rI   rL   rJ   s   ``` @r    deprecated_clsrN      s    (/'-R-AF
 Or"   c                     d| d|sdndd|rd|z   z  |rt         j                  nt         j                  fd}|S )Nz.. deprecated:: 1.4 The zC class is considered legacy as of the 1.x series of SQLAlchemy and will be removedbecomes a legacy construct in 2.0.rB   c                 8    t        | j                        S N)rF   r   )rH   rI   rK   warning_clss    r    rL   z#deprecated_20_cls.<locals>.decorate   s(    )((
 	
r"   )r   LegacyAPIWarningr>   )clsnamealternativerI   becomes_legacyrL   rK   rU   s     `  @@r    deprecated_20_clsrZ      s[     ! -.		
  3$$**,,
 Or"   c                       dk(  rt         j                  d |rd dxs dnddt         j                  t         j                  urd z  z   fd	}|S )
a  Decorates a function and issues a deprecation warning on use.

    :param version:
      Issue version in the warning.

    :param message:
      If provided, issue message in the warning.  A sensible default
      is used if not provided.

    :param add_deprecation_to_docstring:
      Default True.  If False, the wrapped function's __doc__ is left
      as-is.  If True, the 'message' is prepended to the docs if
      provided, or sensible default if message is omitted.

    2.0N1.4rA   rB   r,   z$Call to deprecated function %(func)sz (deprecated since: %s)c                 T    t        | t        | j                        z        S )NrD   )enable_warnings)_decorate_with_warningrG   __name__)fnr_   rJ   rK   r   warnings    r    rL   zdeprecated.<locals>.decorate   s0    %d,,+
 	
r"   )r   r>   r7   )r   rK   add_deprecation_to_docstringrc   r_   rL   rJ   s   `` `` @r    
deprecatedre      s    6 %?,,G#]]

 8**c,,,,w66
 
 Or"   c                 <    t        	 d| t        j                  d|S )NrK   rc   r\   )re   r   MovedIn20Warning)rK   kws     r    moved_20rk      s*    (<(<@B r"   c                 h   t        j                  d|       }|rdddd|j                  d         }nd}d| d	|d
|sdndd}d| v r1|j                  dd      }|s|j	                  d      du s
J d| z         |r|d	|z   z  }|rt
        j                  }nt
        j                  }t        d||d|S )Nz^:(attr|func|meth):	attributefunctionmethod)attrrE   methr   	constructzThe rB   z= is considered legacy as of the 1.x series of SQLAlchemy and rP   rQ   rR   z:attr:warn_on_attribute_accessFr_   zattribute %s will emit a warning on read access.  If you *really* want this, add warn_on_attribute_access=True.  Otherwise please add enable_warnings=False.rg   rh   )	rematchgrouppopr2   r   rV   r>   re   )	api_namerX   rY   rj   type_regr   rK   attribute_okrU   s	            r    deprecated_20r{      s    xx-x8H$j(KNN1
 
 ! -.	
  8vv8%@66+,5 ) ,445 3$$**,,HWkHRHHr"   c                       i i i  j                         D ]C  \  }\  }}||<   t        |      |<   |dk(  rt        j                  nt        j                  |<   E  fd}|S )a"  Decorates a function to warn on use of certain parameters.

    e.g. ::

        @deprecated_params(
            weak_identity_map=(
                "0.7",
                "the :paramref:`.Session.weak_identity_map parameter "
                "is deprecated."
            )

        )

    r\   c                   	
 t        j                  |       }|j                  t        t	        |j
                  t        |j
                        t        |j                        z
  d  |j                              t              j                        	t              j                        
nd	t              
|j                  t        	
fd       }| j                  d uxr | j                  xs d}|rDt        |j                         D ci c]  \  }\  }}|d|dk(  rdn|d|xs d c}}}      } ||       }||_        |S c c}}}w )NrM   c                 >   D ]6  }|   ||   |   ||   |   k7  st        |   
|   	|   d       8 v r2t        |      j                        rt           
   	   d       D ]  }||v st        |   
|   	|   d       !  | |i |S N   r   )r!   set
difference)rb   r;   kwargsmcheck_any_kwcheck_defaultscheck_kwdefaultsmessagesversion_warningsversionss       r    warnedz3deprecated_params.<locals>.decorate.<locals>.warnedW  s    # 	QK'F1I,AQK+q	Xa[0H&  (+#$			 x'CK,B,B- #\*\*$\2 	  ;&  (+#$	 t&v&&r"   r,   rA   r\   r]   rB   )r   inspect_getfullargspecr   rG   zipr;   lenr   intersectionr   varkwr   __doc__r	   items)rb   specr   docparamr   rK   	decoratedr   r   r   r   r   specsr   r   s           @@@@r    rL   z#deprecated_params.<locals>.decorateE  sQ   ,,R0==$IIs499~DMM0BBEFMMH !]77AN8}//9HN8}Hzz		' 	' 
	'B jj$39r# 6;[[]  21  '5 0ug=2P PC 2J		s   !E)r   _sanitize_restructured_textr   r>   r7   )r   r   r   rK   rL   r   r   r   s   `    @@@r    deprecated_paramsr   (  s      HH%*[[] 
!!!5g> % "")) 	
@D Or"   c                 f    d }t        j                  dd |       } t        j                  d||       S )Nc                 B    | j                  dd      \  }}|dv r|dz  }|S )Nr   r
   )rE   rq   z()rv   )r   r   names      r    replz)_sanitize_restructured_text.<locals>.repl  s,    ggamt$$DLDr"   z:ref:`(.+) <.*>`c                 *    d| j                  d      z  S )Nz"%s"r   r   )r   s    r    <lambda>z-_sanitize_restructured_text.<locals>.<lambda>  s    !''!*1D r"   z\:(\w+)\:`~?(?:_\w+)?\.?(.+?)`)rt   sub)textr   s     r    r   r     s1     66%'DdKD663T4@@r"   c                    | j                   d uxr | j                   xs d}|||t        |      z  }t        |t        j                        r|dz  }t        ||d      }t        |       t        u rgt        | j                        }||d<   |j                  dd        |j                  dd        t        | j                  | j                  |      } |||   }n|| _         |t        | |      }|t        | |t        |||d              | S )Nr,   rD   @ (Background on SQLAlchemy 2.0 at: :ref:`migration_20_toplevel`)r   r   __dict____weakref__)r   rG   r   r   r   r   typer   rw   ra   	__bases__getattrsetattrr`   )	rH   rI   wtyperK   r   docstring_headerr   clsdictconstructor_fns	            r    rF   rF     s    ++T
!
1ckk
7RC#"+ 66eS99:0 $C)91=93<<(G!$GIKK
D)KKt,s||S]]G<C&!(!5 CK&!(k!:"&"E7GT Jr"   c                 T   t              t        t        j                        rd}nd}t        fd       }| j
                  duxr | j
                  xs d}|+|t        | j                        z  }||z  }t        ||d      } ||       }	||	_        fd|	_	        |	S )z=Wrap a function with a warnings.warn and augmented docstring.r   r,   c                 d     xs |j                  dd      }|st        d        | |i |S )N_sa_skip_warningFr   r   )rw   r!   )rb   r;   r   skip_warningr_   rK   r   r   s       r    r   z&_decorate_with_warning.<locals>.warned  sC    ** 
fjj/
 w1E4"6""r"   NrD   r   c                  "    t         d      S r   )r!   )rK   r   r   s   r    r   z(_decorate_with_warning.<locals>.<lambda>  s    !3%A" r"   )
r   r   r   r   r   r   rG   ra   r   _sa_warn)
rE   r   rK   r   r   r_   doc_onlyr   r   r   s
    ``` `    r    r`   r`     s    
 *'2G%556, 	
 # # ,,d
"
3t||
9rC#Ddmm44H$#C)91=tIII r"   rT   )r   N)__init__)Nr   F)NTNT)NF)NT) r   r0   rt   r-   r,   r   langhelpersr   r   r   r   r	   r   r   r   getenvlowerpy2kr!   r   r8   r<   r?   rN   rZ   re   rk   r{   r   r   rF   r`   rM   r"   r    <module>r      s
   
 	 
  + ' " . *    299!7+1137KK	;;RYY0':@@B G 
  4 04f	" GL J !%:z&IR_DA AE&T KO%r"   