3
6Ad]<  ã               @   s¼   d dl Z 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ddd
œdd„Zdddddddd
œdd„Z	ddd„Z
G dd„ dƒZeƒ Zddd„Zddd„Ze j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   ú‡/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/matplotlib-3.1.1-py3.6-linux-x86_64.egg/matplotlib/cbook/deprecation.pyr      s   
r   Ú FÚ	attribute)Úremovalc      	      C   sž   |dkrddddœj | dƒ}n|r8|r.tdƒ‚dj|ƒ}|std	|rFd
nd|rPdnd  d |rbdnd |rndnd }|r|tnt}||t|||| |||d� ƒS )Nr	   zin 3.1zin 3.2zin 3.3)z2.2z3.0z3.1z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ÚPendingDeprecationWarningr   Údict)	r   Úmessager   r   Úpendingr   r   r   Zwarning_clsr   r   r   Ú_generate_deprecation_warning   s    

8
r   )r   r   r   r   r   r   r   c      
   
   C   s0   t | |||||||d�}ddlm}	 |	|ƒ 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*.

    obj_type : str, optional
        The object type being deprecated.

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

    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*.

    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   é   )Ú_warn_externalN)r   r	   r   )
r   r   r   r   r   r   r   r   Úwarningr   r   r   r   Úwarn_deprecated:   s
    4r   c      	         s    ||||||f‡ ‡fdd„	}|S )aÄ  
    Decorator to mark a function, a class, or a property as deprecated.

    When deprecating a classmethod, a staticmethod, or a property, the
    ``@deprecated`` decorator should go *under* the ``@classmethod``, etc.
    decorator (i.e., `deprecated` should directly decorate the underlying
    callable).

    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():
                ...
            old_function = 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*.

    obj_type : str, optional
        The object type being deprecated; by default, 'function' if decorating
        a function and 'class' if decorating a class.

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

    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*.

    Examples
    --------

        Basic example::

            @deprecated('1.4.0')
            def the_function_to_deprecate():
                pass
    c          
      s2  t ˆtƒr:|d krd}ˆj‰|p$ˆj}ˆj}‡fdd„}ntt ˆtƒr‚d}d ‰|pVˆjj}ˆj}G ‡fdd„dtƒ‰ ‡ ‡fdd„}n,|d krŽd}ˆ‰|pšˆj}ˆj}‡fd	d„}tˆ||||||ˆd
�‰‡‡fdd„}	tj	|pÞdƒj
dƒ}d}
d|› d|
|k�r|
nd› dˆ› d|j
ƒ › �}|�s(|d7 }||	|ƒS )NÚclassc                s*   y
|ˆ _ W n tk
r   Y nX | ˆ _ˆ S )N)r   ÚAttributeErrorÚ__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ƒ j||ƒS )Nr   )r   )r	   r   ÚsuperÚ__get__)ÚselfÚinstanceÚownerr   )Ú	__class__r   r   r   r'   Ð   s    zCdeprecated.<locals>.deprecate.<locals>._deprecated_property.__get__c                s*   |d k	rddl m} |ˆƒ tƒ j||ƒS )Nr   )r   )r	   r   r&   Ú__set__)r(   r)   Úvaluer   )r+   r   r   r   r,   Ö   s    zCdeprecated.<locals>.deprecate.<locals>._deprecated_property.__set__c                s(   |d k	rddl m} |ˆƒ tƒ j|ƒS )Nr   )r   )r	   r   r&   Ú
__delete__)r(   r)   r   )r+   r   r   r   r.   Ü   s    zFdeprecated.<locals>.deprecate.<locals>._deprecated_property.__delete__)r   r   r   r'   r,   r.   Ú__classcell__r   )r   )r+   r   Ú_deprecated_propertyÏ   s   r0   c                s   ˆ ˆj ˆjˆj|d�S )N)ÚfgetÚfsetÚfdelÚdoc)r1   r2   r3   )Ú_r#   )r0   r$   r   r   r%   â   s    Úfunctionc                s   t jˆ ƒ| ƒ} || _| S )N)Ú	functoolsÚwrapsr   )r"   r#   )r   r   r   r%   í   s    )r   c                 s   ddl m} |ˆƒ ˆ | |ŽS )Nr   )r   )r	   r   )ÚargsÚkwargsr   )r   r   r   r   r"   ö   s    z.deprecated.<locals>.deprecate.<locals>.wrapperr	   Ú
z
Notes
-----z[*Deprecated*] z
.. deprecated:: z
   z\ )Ú
isinstanceÚtyper!   r   r   Úpropertyr1   r   ÚinspectÚcleandocÚstrip)r$   r   r   r   r   r   r   Zold_docr%   r"   Znotes_headerr#   )r   r   )r0   r   r$   r   r   Ú	deprecate·   s<    



.zdeprecated.<locals>.deprecater   )	r   r   r   r   r   r   r   r   rB   r   )r   r   r   Ú
deprecatedu   s    BRrC   c                s†   ˆ dkrt jtˆˆˆƒS tjˆ ƒ}ˆ|jksDtdˆ›dˆ j› d�ƒ‚ˆ|jksftdˆ›dˆ j› d�ƒ‚t jˆ ƒ‡ ‡‡‡fdd„ƒ}|S )aŠ  
    Decorator indicating that parameter *old* of *func* is renamed to *new*.

    The actual implementation of *func* should use *new*, not *old*.  If *old*
    is passed to *func*, a DeprecationWarning is emitted, and its value is
    used, even if *new* is also passed by keyword (this is to simplify pyplot
    wrapper functions, which always pass *new* explicitly to the Axes method).
    If *new* is also passed but positionally, a TypeError will be raised by the
    underlying function during argument binding.

    Examples
    --------

    ::
        @_rename_parameter("3.1", "bad_name", "good_name")
        def func(good_name): ...
    NzMatplotlib internal error: z cannot be a parameter for z()z must be a parameter for c                 sH   ˆ|kr>t ˆdˆ›dˆ j› dˆ›dˆ› d�	d� |jˆƒ|ˆ< ˆ | |ŽS )NzThe z parameter of z() has been renamed z since Matplotlib z7; support for the old name will be dropped %(removal)s.)r   )r   r   Úpop)r9   r:   )r   ÚnewÚoldr   r   r   r"   +  s
    &z"_rename_parameter.<locals>.wrapper)	r7   ÚpartialÚ_rename_parameterr?   Ú	signatureÚ
parametersÚAssertionErrorr   r8   )r   rF   rE   r   rI   r"   r   )r   rE   rF   r   r   rH     s    
rH   c               @   s   e Zd Zdd„ ZdS )Ú_deprecated_parameter_classc             C   s   dS )Nz<deprecated parameter>r   )r(   r   r   r   Ú__repr__>  s    z$_deprecated_parameter_class.__repr__N)r   r   r   rM   r   r   r   r   rL   =  s   rL   c                s‚   ˆ dkrt jtˆˆƒS tjˆ ƒ}ˆ|jksBtdˆ›dˆ j› d�ƒ‚|j‡fdd„|jj	ƒ D ƒd�ˆ _
t jˆ ƒ‡ ‡‡fdd	„ƒ}|S )
a†  
    Decorator indicating that parameter *name* of *func* is being deprecated.

    The actual implementation of *func* should keep the *name* parameter in its
    signature.

    Parameters that come after the deprecated parameter effectively become
    keyword-only (as they cannot be passed positionally without triggering the
    DeprecationWarning on the deprecated parameter), and should be marked as
    such after the deprecation period has passed and the deprecated parameter
    is removed.

    Examples
    --------

    ::
        @_delete_parameter("3.1", "unused")
        def func(used_arg, other_arg, unused, more_args): ...
    NzMatplotlib internal error: z must be a parameter for z()c                s&   g | ]}|j ˆ kr|jtd �n|‘qS ))Údefault)r   ÚreplaceÚ_deprecated_parameter)Ú.0Úparam)r   r   r   ú
<listcomp>b  s   z%_delete_parameter.<locals>.<listcomp>)rJ   c                 sV   ˆ j j| |Žj}ˆ|krL|ˆ tkrLtˆdˆ›dˆ j› dˆ› dˆ›d�	d� ˆ | |ŽS )NzThe z parameter of z"() is deprecated since Matplotlib z< and will be removed %(removal)s.  If any parameter follows z3, they should be pass as keyword, not positionally.)r   )Ú__signature__ÚbindÚ	argumentsrP   r   r   )r9   r:   rV   )r   r   r   r   r   r"   f  s
    &z"_delete_parameter.<locals>.wrapper)r7   rG   Ú_delete_parameterr?   rI   rJ   rK   r   rO   ÚvaluesrT   r8   )r   r   r   rI   r"   r   )r   r   r   r   rW   E  s    

rW   c                sÎ   ˆdkrt jtˆˆƒS tjˆƒ‰tjj‰ tjj}ˆˆjkrJˆjˆ j	ˆ ksbt
dˆ›dˆj› d�ƒ‚ˆj•}‡ ‡fdd„||jˆƒd… D ƒ‰ˆj‡fdd„ˆjjƒ D ƒd�ˆ_t jˆƒ‡‡‡‡fd	d
„ƒ}|S )a“  
    Decorator indicating that passing parameter *name* (or any of the following
    ones) positionally to *func* is being deprecated.

    Note that this decorator **cannot** be applied to a function that has a
    pyplot-level wrapper, as the wrapper always pass all arguments by keyword.
    If it is used, users will see spurious DeprecationWarnings every time they
    call the pyplot wrapper.
    NzMatplotlib internal error: z/ must be a positional-or-keyword parameter for z()c                s    g | ]}ˆj | jˆ kr|‘qS r   )rJ   Úkind)rQ   r   )ÚPOKrI   r   r   rS   Œ  s    z&_make_keyword_only.<locals>.<listcomp>c                s*   g | ]"}|j ˆ kr"|jtjjd �n|‘qS ))rY   )r   rO   r?   Ú	ParameterÚKEYWORD_ONLY)rQ   rR   )Úkwonlyr   r   rS   �  s   )rJ   c                 sB   ˆj | |Ž}ˆ|jkr8ˆ|kr8tˆdˆdˆ j› d�d� ˆ | |ŽS )NzŒPassing the %(name)s %(obj_type)s positionally is deprecated since Matplotlib %(since)s; the parameter will become keyword-only %(removal)s.zparameter of z())r   r   r   )rU   rV   r   r   )r9   r:   Úbound)r   r   rI   r   r   r   r"   ”  s    z#_make_keyword_only.<locals>.wrapper)r7   rG   Ú_make_keyword_onlyr?   rI   r[   ÚPOSITIONAL_OR_KEYWORDr\   rJ   rY   rK   r   ÚindexrO   rX   rT   r8   )r   r   r   ZKWOÚnamesr"   r   )rZ   r   r]   r   rI   r   r   r_   v  s    

"
r_   c            
   c   s*   t jƒ � t jdtƒ d V  W d Q R X d S )NÚignore)ÚwarningsÚcatch_warningsÚsimplefilterr   r   r   r   r   Ú(_suppress_matplotlib_deprecation_warning¢  s    
rg   )r	   r	   r	   Fr
   r	   )N)N)N)Ú
contextlibr7   r?   rd   ÚUserWarningr   ÚmplDeprecationr   r   rC   rH   rL   rP   rW   r_   Úcontextmanagerrg   r   r   r   r   Ú<module>   s$    !9 
0
1
,