
    8xd|%                        d dl mZ d dlZd dlmZ d dlmZ d dlmZm	Z	 d dl
mZmZ ddlmZ  G d	 d
e          Z G d d          Z ee          ZdS )    )annotationsN)wraps)
ModuleType)AnyCallable)Versionparse   )__version__c                      e Zd ZdS )DeprecatedErrorN)__name__
__module____qualname__     8lib/python3.11/site-packages/conda_build/deprecations.pyr   r      s        Dr   r   c                      e Zd ZU ded<   d$dZdddd%dZddddd&dZdddd'dZdddd(dZdddd)dZ	d*d Z
d+d#ZdS ),DeprecationHandlerr   _versionversionVersion | strc                z    	 t          |          | _        dS # t          $ r t          d          | _        Y dS w xY w)zFactory to create a deprecation handle for the specified version.

        :param version: The version to compare against when checking deprecation statuses.
        z0.0.0.dev0+placeholderN)r	   r   	TypeError)selfr   s     r   __init__zDeprecationHandler.__init__   sI    
	<!'NNDMMM 	< 	< 	<!":;;DMMMM	<s    ::Nr   )addendumstackdeprecate_instr	remove_inr   
str | Noner   intreturnCallable[Callable, Callable]c               $     d fd}|S )ar  Deprecation decorator for functions, methods, & classes.

        :param deprecate_in: Version in which code will be marked as deprecated.
        :param remove_in: Version in which code is expected to be removed.
        :param addendum: Optional additional messaging. Useful to indicate what to do instead.
        :param stack: Optional stacklevel increment.
        funcr   r$   c                                           j         d j                   \  st                    t	                      fd            }|S )N.r   c                 H    t          j        dz               | i |S N   
stacklevel)warningswarn)argskwargscategoryr'   messager   s     r   innerzHDeprecationHandler.__call__.<locals>.deprecated_decorator.<locals>.innerB   s3    gxAIFFFFtT,V,,,r   _generate_messager   r   r   r   )	r'   r6   r4   r5   r   r   r!   r   r   s	   ` @@r   deprecated_decoratorz9DeprecationHandler.__call__.<locals>.deprecated_decorator4   s     $ 6 6?88T%688!	 !7 ! !Hg  /%g... 4[[- - - - - - - [-
 Lr   r'   r   r$   r   r   )r   r   r!   r   r   r9   s   ````` r   __call__zDeprecationHandler.__call__$   sA     	 	 	 	 	 	 	 	 	 	, $#r   )renamer   r   argumentr<   c               ,     d fd}|S )a  Deprecation decorator for keyword arguments.

        :param deprecate_in: Version in which code will be marked as deprecated.
        :param remove_in: Version in which code is expected to be removed.
        :param argument: The argument to deprecate.
        :param rename: Optional new argument name.
        :param addendum: Optional additional messaging. Useful to indicate what to do instead.
        :param stack: Optional stacklevel increment.
        r'   r   r$   c           
          	                      j         d j         d drsd dn          \  st                    t	                      
fd            }|S )Nr)   ()zUse 'z
' instead.r*   c                     |v rHt          j        dz              |                    d           }r|                    |            | i |S r,   )r0   r1   pop
setdefault)	r2   r3   valuer=   r4   r'   r5   r<   r   s	      r   r6   zHDeprecationHandler.argument.<locals>.deprecated_decorator.<locals>.innerq   ss     v%%M'8E	JJJJ #JJx66E 9))&%888tT,V,,,r   r7   )r'   r6   r4   r5   r   r=   r   r!   r<   r   r   s   ` @@r   r9   z9DeprecationHandler.argument.<locals>.deprecated_decorator`   s     $ 6 6?DDT%6DDDDD "*33333 !7 ! !Hg  /%g... 4[[
- 
- 
- 
- 
- 
- 
- 
- 
- [
- Lr   r:   r   )r   r   r!   r=   r<   r   r   r9   s   ``````` r   r=   zDeprecationHandler.argumentL   sN    (	 	 	 	 	 	 	 	 	 	 	 	@ $#r   Nonec               r    |                      |||                     |          d         |d|z              dS )a[  Deprecation function for modules.

        :param deprecate_in: Version in which code will be marked as deprecated.
        :param remove_in: Version in which code is expected to be removed.
        :param addendum: Optional additional messaging. Useful to indicate what to do instead.
        :param stack: Optional stacklevel increment.
        r
   r-   )r   r!   topicr   r   N)rH   _get_module)r   r   r!   r   r   s        r   modulezDeprecationHandler.module   sO     	

%""5))!,e) 	 	
 	
 	
 	
 	
r   constantrE   r   c                  	
 |                                \  }
|                     ||
 d |          \  		st                    t          |dd          d		
fd}||_        dS )
a  Deprecation function for module constant/global.

        :param deprecate_in: Version in which code will be marked as deprecated.
        :param remove_in: Version in which code is expected to be removed.
        :param constant:
        :param value:
        :param addendum: Optional additional messaging. Useful to indicate what to do instead.
        :param stack: Optional stacklevel increment.
        r)   __getattr__Nnamer    r$   r   c                    | k    rt          j        dz              S r |           S t          d d|  d          )Nr-   r.   zmodule 'z' has no attribute '')r0   r1   AttributeError)rN   r4   rK   fullnamer5   r   super_getattrrE   s    r   rM   z0DeprecationHandler.constant.<locals>.__getattr__   sh    xgxAIFFFF +$}T*** !QH!Q!Q$!Q!Q!QRRRr   )rN   r    r$   r   )rI   r8   r   getattrrM   )r   r   r!   rK   rE   r   r   rJ   rM   r4   rR   r5   rS   s      `` `  @@@@r   rK   zDeprecationHandler.constant   s    (  ++E22 22$$($$	
 
'  	+!'***  t<<	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S )r   rH   c                   |                      ||||          \  }}|st          |          t          j        ||d|z              dS )a  Deprecation function for a topic.

        :param deprecate_in: Version in which code will be marked as deprecated.
        :param remove_in: Version in which code is expected to be removed.
        :param topic: The topic being deprecated.
        :param addendum: Optional additional messaging. Useful to indicate what to do instead.
        :param stack: Optional stacklevel increment.
        r-   r.   N)r8   r   r0   r1   )r   r   r!   rH   r   r   r4   r5   s           r   rH   zDeprecationHandler.topic   sb    $ !22)UH
 
'
  	+!'*** 	gxAI>>>>>>r   tuple[ModuleType, str]c                    ddl }	 |                                d|z            }|                    |d                   }||j        fS # t          t
          f$ r t          d          dw xY w)zDetect the module from which we are being called.

        :param stack: The stacklevel increment.
        :return: The module and module name.
        r   Nr-   z&unable to determine the calling module)inspectr   	getmoduler   
IndexErrorrQ   r   )r   r   rX   framerJ   s        r   rI   zDeprecationHandler._get_module   s     		VMMOOAI.E&&uQx00FFO,,N+ 	V 	V 	V!"JKKQUU	Vs   A A "A)prefix tuple[type[Warning] | None, str]c           	        t          |          }t          |          }| j        |k     rt          }d| d}n!| j        |k     rt          }d| d}nd}d| d}|d                    t          d|||g                    fS )a  Deprecation decorator for functions, methods, & classes.

        :param deprecate_in: Version in which code will be marked as deprecated.
        :param remove_in: Version in which code is expected to be removed.
        :param prefix: The message prefix, usually the function name.
        :param addendum: Additional messaging. Useful to indicate what to do instead.
        :return: The warning category (if applicable) and the message.
        z.is pending deprecation and will be removed in r)   z%is deprecated and will be removed in Nzwas slated for removal in  )r	   r   PendingDeprecationWarningDeprecationWarningjoinfilter)	r   r   r!   r\   r   deprecate_versionremove_versionr4   warnings	            r   r8   z$DeprecationHandler._generate_message   s     ",//y))=,,,0HSySSSGG]^++)HJiJJJGGH?9???G HHVD67H"=>>??
 	
r   )r   r   )
r   r    r!   r    r   r"   r   r#   r$   r%   )r   r    r!   r    r=   r    r<   r"   r   r"   r   r#   r$   r%   )
r   r    r!   r    r   r"   r   r#   r$   rF   )r   r    r!   r    rK   r    rE   r   r   r"   r   r#   r$   rF   )r   r    r!   r    rH   r    r   r"   r   r#   r$   rF   )r   r#   r$   rV   )
r   r    r!   r    r\   r    r   r    r$   r]   )r   r   r   __annotations__r   r;   r=   rJ   rK   rH   rI   r8   r   r   r   r   r      s&        < < < <  $&$ &$ &$ &$ &$ &$\ "#4$ 4$ 4$ 4$ 4$ 4$v  $
 
 
 
 
 
<  $.) .) .) .) .) .)l  $? ? ? ? ? ?:V V V V
 
 
 
 
 
r   r   )
__future__r   r0   	functoolsr   typesr   typingr   r   packaging.versionr   r	   r   RuntimeErrorr   r   
deprecatedr   r   r   <module>ro      s   
 # " " " " "                              , , , , , , , , $ $ $ $ $ $	 	 	 	 	l 	 	 	y
 y
 y
 y
 y
 y
 y
 y
x  ,,


r   