3
ûâde+  ã            	   @   sØ   U d Z ddlZddlZddlmZmZmZmZmZ ddl	m
Z
 ddlmZ dZG dd„ deƒZdaedeeef ee eeee ee dd	œd
d„Zddœdd„Zdddœeee ee ee ee ddœdd„ZdS )zN
A module that implements tooling to enable easy warnings about deprecations.
é    N)ÚAnyÚOptionalÚTextIOÚTypeÚUnion)Úparse)Ú__version__zDEPRECATION: c               @   s   e Zd ZdS )ÚPipDeprecationWarningN)Ú__name__Ú
__module__Ú__qualname__© r   r   ú>/tmp/pip-build-red6nood/pip/pip/_internal/utils/deprecation.pyr	      s   r	   )ÚmessageÚcategoryÚfilenameÚlinenoÚfileÚlineÚreturnc             C   sZ   |d k	r$t d k	rVt | |||||ƒ n2t|tƒrDtjdƒ}|j| ƒ nt | |||||ƒ d S )Nzpip._internal.deprecations)Ú_original_showwarningÚ
issubclassr	   ÚloggingÚ	getLoggerÚwarning)r   r   r   r   r   r   Úloggerr   r   r   Ú_showwarning   s    

r   )r   c               C   s(   t jdtdd� td kr$t jatt _d S )NÚdefaultT)Úappend)ÚwarningsÚsimplefilterr	   r   Úshowwarningr   r   r   r   r   Úinstall_warning_logger,   s    r"   )Úfeature_flagÚissue)ÚreasonÚreplacementÚgone_inr#   r$   r   c             C   s„   |dk	ot tƒt |ƒk}| t› d�f||s.dndf|df||sBdndf|dfg}djd	d
„ |D ƒƒ}|rpt|ƒ‚tj|tdd� dS )a   Helper to deprecate existing functionality.

    reason:
        Textual reason shown to the user about why this functionality has
        been deprecated. Should be a complete sentence.
    replacement:
        Textual suggestion shown to the user about what alternative
        functionality they can use.
    gone_in:
        The version of pip does this functionality should get removed in.
        Raises an error if pip's current version is greater than or equal to
        this.
    feature_flag:
        Command-line flag of the form --use-feature={feature_flag} for testing
        upcoming functionality.
    issue:
        Issue number on the tracker that would serve as a useful place for
        users to find related discussion and provide feedback.
    Nz{}z*pip {} will enforce this behaviour change.z*Since pip {}, this is no longer supported.zA possible replacement is {}.zEYou can use the flag --use-feature={} to test the upcoming behaviour.z@Discussion can be found at https://github.com/pypa/pip/issues/{}ú c             s   s,   | ]$\}}|d k	r|d k	r|j |ƒV  qd S )N)Úformat)Ú.0ÚvalueZ
format_strr   r   r   ú	<genexpr>o   s   zdeprecated.<locals>.<genexpr>é   )r   Ú
stacklevel)r   Úcurrent_versionÚDEPRECATION_MSG_PREFIXÚjoinr	   r   Úwarn)r%   r&   r'   r#   r$   Zis_goneZmessage_partsr   r   r   r   Ú
deprecated7   s$    
r3   )NN)Ú__doc__r   r   Útypingr   r   r   r   r   Zpip._vendor.packaging.versionr   Úpipr   r/   r0   ÚWarningr	   r   ÚstrÚintr   r"   r3   r   r   r   r   Ú<module>   s   	 " 