HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/site-packages/pip/_internal/network/__pycache__/download.cpython-37.pyc
B

L��g��@sTdZddlZddlZddlZddlZddlmZmZm	Z	ddl
mZmZddl
mZddlmZddlmZddlmZdd	lmZdd
lmZddlmZmZmZddlmZmZm Z e�!e"�Z#eee$d
�dd�Z%eee&ee'd�dd�Z(e&e&d�dd�Z)e&e&e&d�dd�Z*eee&d�dd�Z+eeed�dd�Z,Gdd �d �Z-Gd!d"�d"�Z.dS)#z)Download files with progress indicators.
�N)�Iterable�Optional�Tuple)�CONTENT_CHUNK_SIZE�Response)�get_download_progress_renderer)�NetworkConnectionError)�PyPI)�Link)�
is_from_cache)�
PipSession)�HEADERS�raise_for_status�response_chunks)�format_size�redact_auth_from_url�splitext)�resp�returnc
Cs.yt|jd�Stttfk
r(dSXdS)Nzcontent-length)�int�headers�
ValueError�KeyError�	TypeError)r�r�B/tmp/pip-unpacked-wheel-hv55ucu3/pip/_internal/network/download.py�_get_http_response_sizesr)r�link�progress_barrc	Cs�t|�}|jtjkr|j}n|j}t|�}|rB|�dt|��d�}t|�rXt	�
d|�nt	�
d|�t	��tj
krxd}n*t|�r�d}n|s�d}n|dkr�d}nd}t|t�}|s�|St||d�}||�S)	Nz (�)zUsing cached %szDownloading %sFTi@�)Zbar_type�size)r�netlocr	�file_storage_domain�show_url�url_without_fragmentrrr�logger�info�getEffectiveLevel�logging�INFOrrr)	rrr�total_length�url�
logged_url�
show_progress�chunksZrendererrrr�_prepare_downloads0
r/)�filenamercCstj�|�S)zJ
    Sanitize the "filename" value from a Content-Disposition header.
    )�os�path�basename)r0rrr�sanitize_content_filenameHsr4)�content_disposition�default_filenamercCs4tj��}||d<|�d�}|r,tt|��}|p2|S)z�
    Parse the "filename" value from a Content-Disposition header, and
    return the default filename if the result is empty.
    zcontent-typer0)�email�message�Message�	get_paramr4�str)r5r6�mr0rrr�parse_content_dispositionOs

r=)rrrcCs�|j}|j�d�}|r t||�}t|�d}|sPt�|j�dd��}|rP||7}|s~|j|jkr~tj	�|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�zcontent-type�)
r0r�getr=r�	mimetypes�guess_extensionr+r1r2)rrr0r5�extrrr�_get_http_response_filename^s
rD)�sessionrrcCs.|j�dd�d}|j|tdd�}t|�|S)N�#r>rT)r�stream)r+�splitr@r
r)rEr�
target_urlrrrr�_http_get_downloadssrJc@s8eZdZeedd�dd�Zeeeeefd�dd�ZdS)�
DownloaderN)rErrcCs||_||_dS)N)�_session�
_progress_bar)�selfrErrrr�__init__{szDownloader.__init__)r�locationrc
Cs�yt|j|�}WnDtk
rT}z&|jdk	s0t�t�d|jj|��Wdd}~XYnXt||�}t	j
�||�}t|||j
�}t|d��}x|D]}	|�|	�q�WWdQRX|j�dd�}
||
fS)z.Download the file given by link into location.NzHTTP error %s while getting %s�wbzContent-Typer?)rJrLr�response�AssertionErrorr%�critical�status_coderDr1r2�joinr/rM�open�writerr@)rNrrPr�er0�filepathr.�content_file�chunk�content_typerrr�__call__�s

zDownloader.__call__)	�__name__�
__module__�__qualname__rr;rOr
rr^rrrrrKzsrKc@sHeZdZeedd�dd�Zeeeeeeeeeffd�dd�Z	dS)�BatchDownloaderN)rErrcCs||_||_dS)N)rLrM)rNrErrrrrO�szBatchDownloader.__init__)�linksrPrccs�x�|D]�}yt|j|�}WnDtk
r^}z&|jdk	s:t�t�d|jj|��Wdd}~XYnXt||�}t	j
�||�}t|||j
�}t|d��}	x|D]}
|	�|
�q�WWdQRX|j�dd�}|||ffVqWdS)z0Download the files given by links into location.NzHTTP error %s while getting %srQzContent-Typer?)rJrLrrRrSr%rTrUrDr1r2rVr/rMrWrXrr@)rNrcrPrrrYr0rZr.r[r\r]rrrr^�s$


zBatchDownloader.__call__)
r_r`rarr;rOrr
rr^rrrrrb�s
rb)/�__doc__�
email.messager7r(rAr1�typingrrrZpip._vendor.requests.modelsrr�pip._internal.cli.progress_barsr�pip._internal.exceptionsr�pip._internal.models.indexr	�pip._internal.models.linkr
�pip._internal.network.cacher�pip._internal.network.sessionr�pip._internal.network.utilsr
rr�pip._internal.utils.miscrrr�	getLoggerr_r%rrr;�bytesr/r4r=rDrJrKrbrrrr�<module>s4
&