U
    +|jT  ã                   @   sž   d dl Z d dlmZ d dlmZ d dlmZmZ d dlm	Z	 d dl
mZmZ d dlmZ d dlmZ d d	lmZ e  e¡Zd
d„ Zdd„ Zdd„ Zdd„ ZdS )é    N)ÚMessage)Ú
FeedParser)ÚOptionalÚTuple)Úpkg_resources)Ú
specifiersÚversion)ÚDistribution)ÚNoneMetadataError)Údisplay_pathc                 C   s4   | dkrdS t  | ¡}t d tt|ƒ¡¡}||kS )a˜  
    Check if the given Python version matches a "Requires-Python" specifier.

    :param version_info: A 3-tuple of ints representing a Python
        major-minor-micro version to check (e.g. `sys.version_info[:3]`).

    :return: `True` if the given Python version satisfies the requirement.
        Otherwise, return `False`.

    :raises InvalidSpecifier: If `requires_python` has an invalid format.
    NTÚ.)r   ÚSpecifierSetr   ÚparseÚjoinÚmapÚstr)Úrequires_pythonÚversion_infoÚrequires_python_specifierÚpython_version© r   úeC:\Users\snmko\Desktop\web_content\django_cbt\venv\Lib\site-packages\pip/_internal/utils/packaging.pyÚcheck_requires_python   s
    
r   c                 C   s€   d}t | tjƒr&|  |¡r&|  |¡}n0|  d¡r@d}|  |¡}nt dt| jƒ¡ d}|dkrht	| |ƒ‚t
ƒ }| |¡ | ¡ S )z�
    :raises NoneMetadataError: if the distribution reports `has_metadata()`
        True but `get_metadata()` returns None.
    ÚMETADATAzPKG-INFOzNo metadata found in %sÚ N)Ú
isinstancer   ÚDistInfoDistributionÚhas_metadataÚget_metadataÚloggerÚwarningr   Úlocationr
   r   ÚfeedÚclose)ÚdistÚmetadata_nameÚmetadataÚfeed_parserr   r   r   r   &   s    ÿ


r   c                 C   s&   t | ƒ}| d¡}|dk	r"t|ƒ}|S )z_
    Return the "Requires-Python" metadata for a distribution, or None
    if not present.
    zRequires-PythonN)r   Úgetr   )r$   Úpkg_info_dictr   r   r   r   Úget_requires_pythonB   s
    
r*   c                 C   s2   |   d¡r.|  d¡D ]}| ¡ r| ¡   S qdS )NÚ	INSTALLERr   )r   Úget_metadata_linesÚstrip)r$   Úliner   r   r   Úget_installerS   s
    
r/   )ÚloggingÚemail.messager   Úemail.parserr   Útypingr   r   Úpip._vendorr   Zpip._vendor.packagingr   r   Úpip._vendor.pkg_resourcesr	   Úpip._internal.exceptionsr
   Úpip._internal.utils.miscr   Ú	getLoggerÚ__name__r   r   r   r*   r/   r   r   r   r   Ú<module>   s   
