U
    cUh                     @   s   d Z ddlZddlm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 d	ZeeZe
eeeef d
ddZe
eedddZe
eedddZe
eedddZeeedf dddZeedf eddddZdS )z0Support functions for working with wheel files.
    N)Message)Parser)Tuple)
BadZipFileZipFile)canonicalize_name)UnsupportedWheel)   r   )	wheel_zipnamereturnc              
   C   sh   z t | |}t| |}t|}W n4 tk
rT } zt| d| W 5 d}~X Y nX t|| ||fS )zExtract information from the provided wheel, ensuring it meets basic
    standards.

    Returns the name of the .dist-info directory and the parsed WHEEL metadata.
    z has an invalid wheel, N)wheel_dist_info_dirwheel_metadatawheel_versionr   check_compatibility)r
   r   info_dirmetadataversione r   Y/opt/bot/vods_filmes/script/venv/lib/python3.8/site-packages/pip/_internal/utils/wheel.pyparse_wheel   s    

$
r   )sourcer   r   c                 C   s   dd |   D }dd |D }|s,tdt|dkrLtdd||d	 }t|}t|}||std
|d||S )zReturns the name of the contained .dist-info directory.

    Raises AssertionError or UnsupportedWheel if not found, >1 found, or
    it doesn't match the provided name.
    c                 S   s   h | ]}| d dd qS )/r	   r   )split).0pr   r   r   	<setcomp>-   s     z&wheel_dist_info_dir.<locals>.<setcomp>c                 S   s   g | ]}| d r|qS )z
.dist-info)endswith)r   sr   r   r   
<listcomp>/   s     
 z'wheel_dist_info_dir.<locals>.<listcomp>z.dist-info directory not foundr	   z)multiple .dist-info directories found: {}z, r   z.dist-info directory z does not start with )namelistr   lenformatjoinr   
startswith)r   r   ZsubdirsZ	info_dirsr   Zinfo_dir_namecanonical_namer   r   r   r   &   s     
r   )r   pathr   c              
   C   sN   z|  |W S  tttfk
rH } ztd|d|W 5 d }~X Y nX d S )Nzcould not read z file: )readr   KeyErrorRuntimeErrorr   )r   r'   r   r   r   r   read_wheel_metadata_fileE   s    r+   )r   dist_info_dirr   c              
   C   sd   | d}t | |}z| }W n6 tk
rV } ztd|d|W 5 d}~X Y nX t |S )ziReturn the WHEEL metadata of an extracted wheel, if possible.
    Otherwise, raise UnsupportedWheel.
    z/WHEELzerror decoding z: N)r+   decodeUnicodeDecodeErrorr   r   parsestr)r   r,   r'   Zwheel_contentsZ
wheel_textr   r   r   r   r   N   s    

&r   .)
wheel_datar   c                 C   s^   | d }|dkrt d| }zttt|dW S  tk
rX   t d|Y nX dS )zbGiven WHEEL metadata, return the parsed Wheel-Version.
    Otherwise, raise UnsupportedWheel.
    zWheel-VersionNzWHEEL is missing Wheel-Version.zinvalid Wheel-Version: )r   striptuplemapintr   
ValueError)r0   Zversion_textr   r   r   r   r   a   s    r   )r   r   r   c              	   C   sR   | d t d kr.td|dtt| n | t krNtddtt|  dS )a  Raises errors or warns if called with an incompatible Wheel-Version.

    pip should refuse to install a Wheel-Version that's a major series
    ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when
    installing a version only minor version ahead (e.g 1.2 > 1.1).

    version: a 2-tuple representing a Wheel-Version (Major, Minor)
    name: name of wheel or package to raise exception about

    :raises UnsupportedWheel: when an incompatible Wheel-Version is given
    r   zB{}'s Wheel-Version ({}) is not compatible with this version of pipr1   z*Installing from a newer Wheel-Version (%s)N)VERSION_COMPATIBLEr   r#   r$   r4   strloggerwarning)r   r   r   r   r   r   q   s     r   )__doc__loggingemail.messager   email.parserr   typingr   zipfiler   r   pip._vendor.packaging.utilsr   pip._internal.exceptionsr   r7   	getLogger__name__r9   r8   r   r   bytesr+   r   r5   r   r   r   r   r   r   <module>   s   
	