U
    Z+d$                     @   sd   d Z ddlZddlmZ ddlmZmZ dZdZdZ	dd	d
Z
dddZdddZG dd dZdS )zDeprecation utilities.    Nwraps)CDeprecationWarningCPendingDeprecationWarning)CallablePropertywarnz
    {description} is scheduled for deprecation in     version {deprecation} and removal in version v{removal}.     {alternative}
zc
    {description} is deprecated and scheduled for removal in
    version {removal}. {alternative}
   c                 C   sJ   | |||d}|dk	r(t tjf |}nttjf |}tj||d dS )zWarn of (pending) deprecation.)descriptiondeprecationremovalalternativeN)
stacklevel)r   PENDING_DEPRECATION_FMTformatr   DEPRECATION_FMTwarningsr   )r
   r   r   r   r   ctxw r   ;/tmp/pip-unpacked-wheel-ucduq0nd/celery/utils/deprecated.pyr      s     r   c                    s    fdd}|S )a  Decorator for deprecated functions.

    A deprecation warning will be emitted when the function is called.

    Arguments:
        deprecation (str): Version that marks first deprecation, if this
            argument isn't set a ``PendingDeprecationWarning`` will be
            emitted instead.
        removal (str): Future version when this feature will be removed.
        alternative (str): Instructions for an alternative solution (if any).
        description (str): Description of what's being deprecated.
    c                    s    t   fdd}|S )Nc                     s0   ddl m} tp| dd | |S )N   )qualname   )r
   r   r   r   r   )Zimportsr   r   )argskwargsr   )r   r   r
   funr   r   r   __inner4   s    z)Callable.<locals>._inner.<locals>.__innerr   )r   r   r   r   r
   r   r   r   _inner2   s    zCallable.<locals>._innerr   r   r   r   r
   r    r   r   r   r   $   s    r   c                    s    fdd}|S )z$Decorator for deprecated properties.c                    s   t |  p| jdS )N)r   r   r   r
   )_deprecated_property__name__r   r   r   r   r    D   s       zProperty.<locals>._innerr   r!   r   r   r   r   A   s    r   c                   @   s@   e Zd ZdddZdddZdd Zdd	 Zd
d Zdd ZdS )r"   Nc                 K   sF   || _ || _|| _|j|j|j  | _| _| _|| _| jdd d S )Nr   r   )_deprecated_property__get_deprecated_property__set_deprecated_property__delr#   
__module____doc__	depreinfo
setdefault)selffgetfsetfdeldocr)   r   r   r   __init__M   s      z_deprecated_property.__init__c                 C   s"   |d kr| S t f | j | |S N)r   r)   r$   )r+   objtyper   r   r   __get__W   s    z_deprecated_property.__get__c                 C   s:   |d kr| S | j d krtdtf | j |  || d S )Nzcannot set attribute)r%   AttributeErrorr   r)   )r+   r2   valuer   r   r   __set__]   s    
z_deprecated_property.__set__c                 C   s8   |d kr| S | j d krtdtf | j |  | d S )Nzcannot delete attribute)r&   r5   r   r)   )r+   r2   r   r   r   
__delete__e   s    
z_deprecated_property.__delete__c                 C   s   | j | j|| jf| jS r1   )	__class__r$   r&   r)   )r+   r-   r   r   r   setterm   s    z_deprecated_property.setterc                 C   s   | j | j| j|f| jS r1   )r9   r$   r%   r)   )r+   r.   r   r   r   deleterp   s    z_deprecated_property.deleter)NNNN)N)	r#   r'   __qualname__r0   r4   r7   r8   r:   r;   r   r   r   r   r"   K   s   


r"   )NNNNr	   )NNNN)NNNN)r(   r   Z
vine.utilsr   Zcelery.exceptionsr   r   __all__r   r   r   r   r   r"   r   r   r   r   <module>   s(         
    
    

