관리-도구
편집 파일: download.cpython-310.pyc
o ƚRe� � @ sj d Z ddlZddlZddlZddlZddlmZmZmZ ddl m Z mZ ddlm Z ddlmZ ddlmZ ddlmZ dd lmZ dd lmZ ddlmZmZmZ ddlmZmZmZ e� e!�Z"d edee# fdd�Z$d edede%dee& fdd�Z'de%de%fdd�Z(de%de%de%fdd�Z)d edede%fdd�Z*dededefdd �Z+G d!d"� 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, zt | jd �W S tttfy Y d S w )Nzcontent-length)�int�headers� ValueError�KeyError� TypeError)r � r ��/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/network/download.py�_get_http_response_size s �r �link�progress_barc C s� t | �}|jtjkr|j}n|j}t|�}|rd�|t|��}t | �r*t �d|� nt �d|� t �� t jkr:d}nt | �rAd}n|sFd}n |dkrMd}nd}t| t�}|sX|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 r r �total_length�url� logged_url� show_progress�chunksr r r �_prepare_download s. r/ �filenamec C s t j�| �S )zJ Sanitize the "filename" value from a Content-Disposition header. )�os�path�basename)r0 r r r �sanitize_content_filenameG s r4 �content_disposition�default_filenamec C s, t �| �\}}|�d�}|rt|�}|p|S )z� Parse the "filename" value from a Content-Disposition header, and return the default filename if the result is empty. r0 )�cgi�parse_header�getr4 )r5 r6 �_type�paramsr0 r r r �parse_content_dispositionN s r<