| Server IP : 127.0.0.1 / Your IP : 216.73.216.109 Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10 System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64 User : SERVERWEB ( 0) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/cygwin64/lib/python3.6/site-packages/pip/_internal/network/__pycache__/ |
Upload File : |
3
�N�a� � @ sT d Z ddlZddlZddlZddlZddlmZmZmZ ddl m
Z
mZ ddlm
Z
ddlmZ ddlmZ ddlmZ dd lmZ dd
lmZ ddlmZmZmZ ddlmZmZmZ ej e!�Z"eee# d
�dd�Z$eee%ee& d�dd�Z'e%e%d�dd�Z(e%e%e%d�dd�Z)eee%d�dd�Z*eeed�dd�Z+G dd � d �Z,G d!d"� d"�Z-dS )#z)Download files with progress indicators.
� N)�Iterable�Optional�Tuple)�CONTENT_CHUNK_SIZE�Response)�DownloadProgressProvider)�NetworkConnectionError)�PyPI)�Link)�
is_from_cache)�
PipSession)�HEADERS�raise_for_status�response_chunks)�format_size�redact_auth_from_url�splitext)�resp�returnc
C s. yt | jd �S tttfk
r( d S X d S )Nzcontent-length)�int�headers�
ValueError�KeyError� TypeError)r � r �/usr/lib/python3.6/download.py�_get_http_response_size s r )r �link�progress_barr c C s� t | �}|jtjkr|j}n|j}t|�}|r>dj|t|��}t | �rTt
jd|� nt
jd|� t
j� t
jkrtd}n*t | �r�d}n|s�d}n|d kr�d}nd}t| t�}|s�|S t||d�|�S )
Nz{} ({})zUsing cached %szDownloading %sFT�( i� )�maxi@� )r Znetlocr Zfile_storage_domainZshow_urlZurl_without_fragmentr �formatr r �logger�infoZgetEffectiveLevel�logging�INFOr r r )r r r Ztotal_length�urlZ
logged_urlZ
show_progress�chunksr r r �_prepare_download s.
r( )�filenamer c C s t jj| �S )zJ
Sanitize the "filename" value from a Content-Disposition header.
)�os�path�basename)r) r r r �sanitize_content_filenameG s r- )�content_disposition�default_filenamer c C s, t j| �\}}|jd�}|r$t|�}|p*|S )z�
Parse the "filename" value from a Content-Disposition header, and
return the default filename if the result is empty.
r) )�cgiZparse_header�getr- )r. r/ Z_type�paramsr) r r r �parse_content_dispositionN s
r3 )r r r c C s� |j }| jjd�}|r t||�}t|�d }|sPtj| jjdd��}|rP||7 }| r�|j| jkr�tj j| j�d }|r�||7 }|S )zoGet an ideal filename from the given HTTP response, falling back to
the link filename if not provided.
zcontent-disposition� zcontent-type� )
r) r r1 r3 r � mimetypesZguess_extensionr&