o
    y¬´\…  ã                   @   s„   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d	„Zdd
d„Z	ddd„Z
	ddd„Zdd„ Zddd„Zdd„ Zdd„ ZdS )zSHelpers related to deprecation of functions, methods, classes, other
functionality.é    Né   )Ú	decoratoré   )Úexcé   c                 C   ó   t j| tj|d� d S ©N©Ú
stacklevel)ÚwarningsÚwarnr   ÚSADeprecationWarning©Úmsgr
   © r   úN/var/www/html/env/lib/python3.10/site-packages/sqlalchemy/util/deprecations.pyÚwarn_deprecated   ó   r   c                 C   r   r   )r   r   r   ÚSAPendingDeprecationWarningr   r   r   r   Úwarn_pending_deprecation   r   r   Tc                    ó8   |rd| ˆpdf ‰ nd‰ ˆdu rd‰‡ ‡fd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.

    z.. deprecated:: %s %sÚ Nú$Call to deprecated function %(func)sc                    ó   t | tjˆt| jd� ˆ ƒS ©N©Úfunc)Ú_decorate_with_warningr   r   ÚdictÚ__name__©Úfn©ÚheaderÚmessager   r   Údecorate4   ó   üzdeprecated.<locals>.decorater   ©Úversionr$   Úadd_deprecation_to_docstringr%   r   r"   r   Ú
deprecated   s   r*   c                    r   )aE  Decorates a function and issues a pending deprecation warning on use.

    :param version:
      An approximate future version at which point the pending deprecation
      will become deprecated.  Not used in messaging.

    :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.
    z.. deprecated:: %s (pending) %sr   Nr   c                    r   r   )r   r   r   r   r   r    r"   r   r   r%   Z   r&   z%pending_deprecation.<locals>.decorater   r'   r   r"   r   Úpending_deprecation?   s   r+   c                 C   s   dd„ }t  d|| ¡S )Nc                 S   s$   |   dd¡\}}|dv r|d7 }|S )Nr   r   )r   Úmethz())Úgroup)ÚmÚtype_Únamer   r   r   Úreplf   s   z)_sanitize_restructured_text.<locals>.replz\:(\w+)\:`~?\.?(.+?)`)ÚreÚsub)Útextr1   r   r   r   Ú_sanitize_restructured_texte   s   r5   c                    sd   t ˆ ƒ‰ t‡ ‡fdd„ƒ}| jdur| jpd}|dur)|t| jd�; }t||dƒ}|| ƒ}||_|S )z=Wrap a function with a warnings.warn and augmented docstring.c                    s   t jˆ ˆdd� | |i |¤ŽS )Nr   r	   )r   r   )r!   ÚargsÚkwargs©r$   Úwtyper   r   Úwarnedt   s   z&_decorate_with_warning.<locals>.warnedNr   r   r   )r5   r   Ú__doc__r   r   Úinject_docstring_text)r   r9   r$   Údocstring_headerr:   ÚdocÚ	decoratedr   r8   r   r   o   s   r   c                 C   sJ   |   dd¡}t|ƒdkr| S |\}}| d¡s |d t |¡ S t | ¡S )NÚ
r   ú )ÚsplitÚlenÚ
startswithÚtextwrapÚdedent)r4   Ú
split_textÚ	firstlineÚ	remainingr   r   r   Ú_dedent_docstring„   s   

rJ   c                 C   s”   t | pdƒ} |  d¡}t |¡ d¡}|d r| dd¡ dd„ t|ƒD ƒ}| dd¡ |t|t|ƒd ƒ }|d|… | ||d …  }d |¡S )Nr   r@   r   c                 S   s   g | ]
\}}|  ¡ s|‘qS r   )Ústrip)Ú.0ÚnumÚliner   r   r   Ú
<listcomp>—   s    z)inject_docstring_text.<locals>.<listcomp>r   )	rJ   rB   rE   rF   ÚinsertÚ	enumerateÚminrC   Újoin)ÚdoctextÚ
injecttextÚposÚlinesÚinjectlinesÚblanksÚ
inject_posr   r   r   r<   �   s   

r<   )r   )NT)N)r;   r2   rE   r   Úlanghelpersr   r   r   r   r   r*   r+   r5   r   rJ   r<   r   r   r   r   Ú<module>   s   


%
ÿ&

