o
    i                      @   s   d dl Z d dlZd dlZddlmZ dZdZdZdZ			dd	d
Z			dddZ
G dd deZ			dddZ			dddZ		dddZdS )    N   )_utilsz%s '%s' has moved to '%s'zClass '%s' has moved to '%s'z()zFunction '%s' has moved to '%s'   c           	         s    fdd}|S )z?Decorates a method/property that was moved to another location.c              
      sD   t | \ r7 tj 	f	dd}|| S )Nc           	         sr   t j| dd}r}nd|f}d|f}t||f }t j|d}t j| d | |i |S )NF)fully_qualified.messageversionremoval_version
stacklevelcategory)r   get_class_namejoin_KIND_MOVED_PREFIX_TPLgenerate_messagedeprecation)	wrappedinstanceargskwargs	base_nameold_namenew_nameprefixout_message)	r   r   kindr   new_attribute_nameold_attribute_namer
   r   r	    V/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/vendor/debtcollector/moves.pywrapper&   s   z4_moved_decorator.<locals>.decorator.<locals>.wrapper)r   get_qualified_namewrapt	decoratorfr!   attr_postfixr   r   r   r   r
   r   r	   )r   r   r    r$   !   s   z#_moved_decorator.<locals>.decoratorr   )	r   r   r   r	   r
   r   r(   r   r$   r   r'   r    _moved_decorator   s   r)   c                    s|   t }|t7 }d||g}	|	t7 }	t|	|f }
t j|
|||dtjt d fdd}||_	||_
|S )zDeprecates a function that was moved to another location.

    This generates a wrapper around ``new_func`` that will emit a deprecation
    warning when called. The warning message will include the new location
    to obtain the function from.
    r   r   assignedc                     s   t j d | i |S Nr   r   r   )r   r   r   new_funcr   r   r   r    old_new_funcM   s   z$moved_function.<locals>.old_new_func)r   get_callable_name_MOVED_CALLABLE_POSTFIXr   _FUNC_MOVED_PREFIX_TPLr   	functoolswrapsget_assigned__name__
__module__)r/   old_func_nameold_module_namer   r	   r
   r   r   new_func_full_nameold_func_full_namer   r0   r   r.   r    moved_function;   s   
	r=   c                   @   s&   e Zd ZdZ		dddZdd ZdS )	moved_read_only_propertya  Descriptor for read-only properties moved to another location.

    This works like the ``@property`` descriptor but can be used instead to
    provide the same functionality and also interact with the :mod:`warnings`
    module to warn when a property is accessed, so that users of those
    properties can know that a previously read-only property at a prior
    location/name has moved to another location/name.

    :param old_name: old attribute location/name
    :param new_name: new attribute location/name
    :param version: version string (represents the version this deprecation
                    was created in)
    :param removal_version: version string (represents the version this
                            deprecation will be removed in); a string
                            of '?' will denote this will be removed in
                            some future unknown version
    :param stacklevel: stacklevel used in the :func:`warnings.warn` function
                       to locate where the users code is when reporting the
                       deprecation call (the default being 3)
    :param category: the :mod:`warnings` category to use, defaults to
                     :py:class:`DeprecationWarning` if not provided
    Nr   c                 C   s:   || _ || _tjd| j | jf ||d| _|| _|| _d S )Nz)Read-only property '%s' has moved to '%s')r	   r
   )	_old_name	_new_namer   r   _message_stacklevel	_category)selfr   r   r	   r
   r   r   r   r   r    __init__p   s   

z!moved_read_only_property.__init__c                 C   s4   t j| j| j| jd |d ur|}n|}t|| jS r,   )r   r   rA   rB   rC   getattrr@   )rD   r   owner
real_ownerr   r   r    __get__|   s   z moved_read_only_property.__get__)NNr   N)r7   r8   __qualname____doc__rE   rI   r   r   r   r    r>   X   s    
r>   c              
   C   s*   |  ts	| t7 } td| ||||t|dS )zBDecorates an *instance* method that was moved to another location.Method)r   r	   r
   r   r(   r   )endswithr2   r)   )new_method_namer   r	   r
   r   r   r   r   r    moved_method   s   
rO   c              	   C   s   t d| |||||dS )zDDecorates an *instance* property that was moved to another location.Property)r   r	   r
   r   r   )r)   )r   r   r	   r
   r   r   r   r   r    moved_property   s   rQ   c                    s   t | stt| \}}	td|	 d||f}
t| }t|
|f }tj	||||d fdd}t|| fi }||_
||j|_|S )a;  Deprecates a class that was moved to another location.

    This creates a 'new-old' type that can be used for a
    deprecation period that can be inherited from. This will emit warnings
    when the old locations class is initialized, telling where the new and
    improved location for the old class now is.
    z5Unexpected class type '%s' (expected class type only)r   r   c                    s*   t j t d fdd}|S )Nr*   c                    s&   t j d | g|R i |S r,   r-   )rD   r   r   )r   r&   r   r   r   r    r!      s   z/moved_class.<locals>.decorator.<locals>.wrapper)r4   r5   r   r6   r%   r   r   r   )r&   r    r$      s   zmoved_class.<locals>.decorator)inspectisclassr   r"   type	TypeErrorr   r   _CLASS_MOVED_PREFIX_TPLr   r8   rE   )	new_classold_class_namer:   r   r	   r
   r   r   _qual	type_namer   r   r   r$   	old_classr   rR   r    moved_class   s"   


r]   )NNNr   NN)NNNr   N)r4   rS   r#    r   r   rW   r2   r3   r)   r=   objectr>   rO   rQ   r]   r   r   r   r    <module>   s6   
 
1


