x}@d d Z ddlZddlZddlZddlZddlmZmZmZ ddl m Z mZ ddlm Z ddlmZ ddlmZ ddlmZ dd lmZ dd lmZ ddlmZmZmZ ddlmZmZmZ ej e! Z"d edee# fdZ$d edede%dee& fdZ'de%de%fdZ(de%de%de%fdZ)d edede%fdZ*dededefdZ+ G d d Z, G d d Z-dS )z)Download files with progress indicators. N)IterableOptionalTuple)CONTENT_CHUNK_SIZEResponse)DownloadProgressProvider)NetworkConnectionError)PyPI)Link) is_from_cache) PipSession)HEADERSraise_for_statusresponse_chunks)format_sizeredact_auth_from_urlsplitextrespreturnc t t | j d S # t t t f$ r Y d S w xY w)Nzcontent-length)intheaders ValueErrorKeyError TypeError)r s /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el9.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/network/download.py_get_http_response_sizer sF 4< 01222), tts 77linkprogress_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_domainshow_urlurl_without_fragmentr formatr r loggerinfogetEffectiveLevelloggingINFOr r r )r r r total_lengthurl logged_url show_progresschunkss r _prepare_downloadr1 s: +400L{d...m'%c**J M%%j+l2K2KLL T 2%z2222$j111 !!GL00 t # # T#5 6 6F C#LlCCCFKKK filenamec @ t j | S )zJ Sanitize the "filename" value from a Content-Disposition header. )ospathbasename)r3 s r sanitize_content_filenamer8 G s 7H%%%r2 content_dispositiondefault_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 )cgiparse_headergetr8 )r9 r: _typeparamsr3 s r parse_content_dispositionrA N sM $%899ME6zz*%%H 7 -X66'''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> rA r mimetypesguess_extensionr- r5 r6 )r r r3 r9 exts r _get_http_response_filenamerH \ s }H,**+@AA L,-@(KK!(++A.C '(8(8(L(LMM OH 48tx''gtx((+ OHOr2 sessionc |j dd d }| |t d }t | |S )N#rC r T)r stream)r- splitr> r r )rI r target_urlr s r _http_get_downloadrO q sF Q''*J;;z74;@@DTKr2 c F e Zd ZdededdfdZdededeeef fdZdS ) DownloaderrI r r Nc " || _ || _ d S N_session _progress_barselfrI r s r __init__zDownloader.__init__y )r2 r locationc t | j | }nB# t $ r5}|j J t d|j j | d}~ww xY wt || }t j || }t ||| j }t |d 5 }|D ]} | | ddd n# 1 swxY w Y |j dd } || fS )z.Download the file given by link into location.NHTTP error %s while getting %swbContent-TyperD rO rU r responser' criticalstatus_coderH r5 r6 joinr1 rV openwriter r> )rX r r[ r er3 filepathr0 content_filechunkcontent_types r __call__zDownloader.__call__ sY %dmT::DD% :)))OO0!*2H$ /tT::7<<(33"4t/ABB (D ! ! *\ * *""5)))) * * * * * * * * * * * * * * * * |'';;%%s&