관리-도구
편집 파일: download.cpython-37.pyc
B ��Re � @ s* d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl m Z ddlmZ ddl mZ ddlmZmZmZ dd lmZmZmZ dd lmZ er�ddlmZmZ ddlmZ dd lmZ ddlm Z e�!e"�Z#dd� Z$dd� Z%dd� Z&dd� Z'dd� Z(dd� Z)G dd� de*�Z+G dd� de*�Z,dS )z)Download files with progress indicators. � N)�CONTENT_CHUNK_SIZE)�DownloadProgressProvider)�NetworkConnectionError)�PyPI)� is_from_cache)�HEADERS�raise_for_status�response_chunks)�format_size�redact_auth_from_url�splitext)�MYPY_CHECK_RUNNING)�Iterable�Optional)�Response)�Link)� PipSessionc C s. yt | jd �S tttfk r( d S X d S )Nzcontent-length)�int�headers� ValueError�KeyError� TypeError)�resp� r ��/builddir/build/BUILDROOT/alt-python37-pip-20.2.4-6.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/pip/_internal/network/download.py�_get_http_response_size% s r c C s� t | �}|jtjkr|j}n|j}t|�}|r>d�|t|��}t | �rTt �d|� nt �d|� t �� t jkrtd}n*t | �r�d}n|s�d}n|dkr�d}nd}t| t�}|s�|S t||d�|�S )Nz{} ({})zUsing cached %szDownloading %sFTi@� )�max)r �netlocr �file_storage_domain�show_url�url_without_fragmentr �formatr r �logger�info�getEffectiveLevel�logging�INFOr r r )r �link�progress_bar�total_length�url� logged_url� show_progress�chunksr r r �_prepare_download- s2 r. c C s t j�| �S )zJ Sanitize the "filename" value from a Content-Disposition header. )�os�path�basename)�filenamer r r �sanitize_content_filenameY s r3 c C s, t �| �\}}|�d�}|r$t|�}|p*|S )z� Parse the "filename" value from a Content-Disposition header, and return the default filename if the result is empty. r2 )�cgi�parse_header�getr3 )�content_disposition�default_filename�_type�paramsr2 r r r �parse_content_dispositiona s r; c C s� |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� zcontent-type� ) r2 r r6 r; r � mimetypes�guess_extensionr* r/ r0 )r r'