B
    ]t\$                 @   s`   d dl Z d dlZd dlZG dd deZeZddddd	Zdddd
dZdddddZdS )    Nc               @   s   e Zd ZdZdS )MatplotlibDeprecationWarninga  
    A class for issuing deprecation warnings for Matplotlib users.

    In light of the fact that Python builtin DeprecationWarnings are ignored
    by default as of Python 2.7 (see link below), this class was put in to
    allow for the signaling of deprecation, but via UserWarnings which are not
    ignored by default.

    https://docs.python.org/dev/whatsnew/2.7.html#the-future-for-python-2-x
    N)__name__
__module____qualname____doc__ r   r   ;lib/python3.7/site-packages/matplotlib/cbook/deprecation.pyr      s   
r    F	attribute)removalc         
   C   s   |dkrddd | d}n|r6|r,tdd|}|srd|rDd	nd
|rNdnd  d |r`dnd |rldnd }|t|||| |||d S )Nr	   zin 3.1zin 3.2)z2.2z3.0ztwo minor releases laterz5A pending deprecation cannot have a scheduled removalzin {}zThe %(name)s %(obj_type)sz' will be deprecated in a future versionz' was deprecated in Matplotlib %(since)sz  and will be removed %(removal)s.z Use %(alternative)s instead.z %(addendum)s)funcnameobj_typesincer   alternativeaddendum)get
ValueErrorformatdict)r   messager   r   pendingr   r   r   r   r   r   _generate_deprecation_message   s    


8
r   c      	      C   s<   dt | |||||||d }|r$tnt}tj||dd dS )a  
    Used to display deprecation in a standard way.

    Parameters
    ----------
    since : str
        The release at which this API became deprecated.

    message : str, optional
        Override the default deprecation message.  The format
        specifier `%(name)s` may be used for the name of the function,
        and `%(alternative)s` may be used in the deprecation message
        to insert the name of an alternative to the deprecated
        function.  `%(obj_type)s` may be used to insert a friendly name
        for the type of object being deprecated.

    name : str, optional
        The name of the deprecated object.

    alternative : str, optional
        An alternative API that the user may use in place of the deprecated
        API.  The deprecation warning will tell the user about this alternative
        if provided.

    pending : bool, optional
        If True, uses a PendingDeprecationWarning instead of a
        DeprecationWarning.  Cannot be used together with *removal*.

    removal : str, optional
        The expected removal version.  With the default (an empty string), a
        removal version is automatically computed from *since*.  Set to other
        Falsy values to not schedule a removal date.  Cannot be used together
        with *pending*.

    obj_type : str, optional
        The object type being deprecated.

    addendum : str, optional
        Additional text appended directly to the final message.

    Examples
    --------

        Basic example::

            # To warn of the deprecation of "matplotlib.name_of_module"
            warn_deprecated('1.4.0', name='matplotlib.name_of_module',
                            obj_type='module')

    
)r      )
stacklevelN)r   PendingDeprecationWarningr   warningswarn)	r   r   r   r   r   r   r   r   categoryr   r   r   warn_deprecated6   s    5
r!   c      	         s0   |dk	rt dd |||||f fdd	}|S )a'  
    Decorator to mark a function or a class as deprecated.

    Parameters
    ----------
    since : str
        The release at which this API became deprecated.  This is
        required.

    message : str, optional
        Override the default deprecation message.  The format
        specifier `%(name)s` may be used for the name of the object,
        and `%(alternative)s` may be used in the deprecation message
        to insert the name of an alternative to the deprecated
        object.

    name : str, optional
        The name of the deprecated object; if not provided the name
        is automatically determined from the passed in object,
        though this is useful in the case of renamed functions, where
        the new function is just assigned to the name of the
        deprecated function.  For example::

            def new_function():
                ...
            oldFunction = new_function

    alternative : str, optional
        An alternative API that the user may use in place of the deprecated
        API.  The deprecation warning will tell the user about this alternative
        if provided.

    pending : bool, optional
        If True, uses a PendingDeprecationWarning instead of a
        DeprecationWarning.  Cannot be used together with *removal*.

    removal : str, optional
        The expected removal version.  With the default (an empty string), a
        removal version is automatically computed from *since*.  Set to other
        Falsy values to not schedule a removal date.  Cannot be used together
        with *pending*.

    addendum : str, optional
        Additional text appended directly to the final message.

    Examples
    --------

        Basic example::

            @deprecated('1.4.0')
            def the_function_to_deprecate():
                pass
    Nz3.0zPassing 'obj_type' to the 'deprecated' decorator has no effect, and is deprecated since Matplotlib %(since)s; support for it will be removed %(removal)s.c          
      s4  |s
j }ttr2d}j}jfdd}nttr|d}d |pNjj }j}G fdddt  fdd}n>d}ttrjj}fd	d}nj}fd
d}t	|||||d|rt
ntfdd}	t|pdd} dd | }
|s*|
d7 }
||	|
S )Nclassc                s   | _ |  _ S )N)r   __init__)wrappernew_doc)objr   r   finalize   s    z/deprecated.<locals>.deprecate.<locals>.finalizer
   c                   s@   e Zd Z fddZ fddZ fddZ  ZS )z;deprecated.<locals>.deprecate.<locals>._deprecated_propertyc                s,   |d k	rddl m} | t ||S )N   )_warn_external)r	   r)   super__get__)selfinstanceownerr)   )	__class__r    r   r   r   r+      s    
zCdeprecated.<locals>.deprecate.<locals>._deprecated_property.__get__c                s,   |d k	rddl m} | t ||S )Nr(   )r)   )r	   r)   r*   __set__)r,   r-   valuer)   )r/   r    r   r   r   r0      s    
zCdeprecated.<locals>.deprecate.<locals>._deprecated_property.__set__c                s*   |d k	rddl m} | t |S )Nr(   )r)   )r	   r)   r*   
__delete__)r,   r-   r)   )r/   r    r   r   r   r2      s    
zFdeprecated.<locals>.deprecate.<locals>._deprecated_property.__delete__)r   r   r   r+   r0   r2   __classcell__r   )r    r   )r/   r   _deprecated_property   s   r4   c                s    j jj|dS )N)fgetfsetfdeldoc)r5   r6   r7   )_r%   )r4   r&   r   r   r'      s    Zfunctionc                s   t  | } || _t| S )N)	functoolswrapsr   classmethod)r$   r%   )r   r   r   r'      s    c                s   t  | } || _| S )N)r:   r;   r   )r$   r%   )r   r   r   r'      s    )r   c                 s   t j dd | |S )Nr   )r   )r   r   )argskwargs)r    r   r   r   r   r$      s    z.deprecated.<locals>.deprecate.<locals>.wrapperr	   r   z,
.. deprecated:: %(since)s
    %(message)s

)r   r   z\ )r   
isinstancetyper   r#   propertyr5   r<   __func__r   r   r   textwrapdedentstrip)r&   r   r   r   r   r   r   Zold_docr'   r$   r%   )r   r   )r4   r    r   r   r&   r   	deprecate   sF    


zdeprecated.<locals>.deprecate)r!   )	r   r   r   r   r   r   r   r   rF   r   )r   r   r   
deprecateds   s    9UrG   )r	   r	   r	   Fr
   r	   )r	   r	   r	   Fr
   r	   )r	   r	   r	   FNr	   )	r:   rC   r   UserWarningr   ZmplDeprecationr   r!   rG   r   r   r   r   <module>   s     ; 