관리-도구
편집 파일: download.cpython-311.pyc
� �Re� � � � d Z ddlZddlZddlZddlZddlmZmZmZ ddl m Z mZ ddlm Z ddlmZ ddlmZ ddlmZ dd lmZ dd lmZ ddlmZmZmZ ddlmZmZmZ ej e!� � Z"d edee# fd�Z$d edede%dee& fd�Z'de%de%fd�Z(de%de%de%fd�Z)d edede%fd�Z*dededefd�Z+ G d� d� � Z, G 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 �t � t | j d � � S # t t t f$ r Y d S w xY w)Nzcontent-length)�int�headers� ValueError�KeyError� TypeError)r s ��/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/network/download.py�_get_http_response_sizer sF � ���4�<� 0�1�2�2�2����)�,� � � ��t�t����s � �7�7�link�progress_barc �Z � t | � � }|j t j k r|j }n|j }t |� � }|r#d� |t |� � � � }t | � � rt � d|� � nt � d|� � t � � � t j k rd}n"t | � � rd}n|sd}n|dk rd}nd}t | t � � }|s|S t# ||�� � |� � 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�chunkss r �_prepare_downloadr1 s: � � +�4�0�0�L��{�d�.�.�.��m����'��%�c�*�*�J�� M��%�%�j�+�l�2K�2K�L�L� ��T��� 2����%�z�2�2�2�2����$�j�1�1�1� ���!�!�G�L�0�0�� � � �t� � � �� � � � �� � � �� #� #�� � �� � �T�#5� 6� 6�F�� �� �C�#�L�l�C�C�C�F�K�K�K� �filenamec �@ � t j � | � � S )zJ Sanitize the "filename" value from a Content-Disposition header. )�os�path�basename)r3 s r �sanitize_content_filenamer8 G s � � �7���H�%�%�%r2 �content_disposition�default_filenamec � � t j | � � \ }}|� d� � }|rt |� � }|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�getr8 )r9 r: �_type�paramsr3 s r �parse_content_dispositionrA N sM � � �$�%8�9�9�M�E�6��z�z�*�%�%�H�� 7� -�X�6�6���'�'�'r2 c � � |j }| j � d� � }|rt ||� � }t |� � d }|s4t j | j � dd� � � � }|r||z }|sA|j | j k r1t j � | j � � d }|r||z }|S )zoGet an ideal filename from the given HTTP response, falling back to the link filename if not provided. zcontent-disposition� zcontent-type� ) r3 r r>