관리-도구
편집 파일: download.cpython-36.pyc
3 �Re � @ s* d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl m Z ddlmZ ddl mZ ddlmZmZmZ dd lmZmZmZ dd lmZ er�ddlmZmZ ddlmZ dd lmZ ddlm Z ej!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-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/network/download.py�_get_http_response_size% s r 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 �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 jj| �S )zJ Sanitize the "filename" value from a Content-Disposition header. )�os�path�basename)�filenamer r r �sanitize_content_filenameY s r4 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. r3 )�cgi�parse_header�getr4 )�content_disposition�default_filename�_type�paramsr3 r r r �parse_content_dispositiona s r<