관리-도구
편집 파일: download.cpython-38.pyc
U ʗRe� � @ sT d Z ddlZddlZddlZddlZddlmZmZm Z ddl mZmZ ddl mZ ddlmZ ddlmZ ddlmZ dd lmZ dd lmZ ddlmZmZmZ ddlmZmZm Z e�!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)�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 C s2 zt | jd �W S tttfk r, Y d S X d S )Nzcontent-length)�int�headers� ValueError�KeyError� TypeError)r � r ��/builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/network/download.py�_get_http_response_size s r )r �link�progress_barr 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@� )�bar_type�size)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�chunks�rendererr r r �_prepare_download s0 r1 )�filenamer c C s t j�| �S )zJ Sanitize the "filename" value from a Content-Disposition header. )�os�path�basename)r2 r r r �sanitize_content_filenameH s r6 )�content_disposition�default_filenamer c C s4 t j�� }| |d<