U 巀g.@sdZddlZddlZddlZddlZddlZddlZddlZddlm Z m Z m Z ddlm Z ddl mZddlmZmZmZmZddlmZeeZeeZzddlZee7ZWnek redYnXzddlZee7ZWn ek red YnXed d d Ze e e d ddZ!e e e"dddZ#e e e"dddZ$ed ddZ%e dd ddZ&e e"dddZ'd*e e e"dddd Z(e e dd!d"d#Z)e e ej*e"dd$d%d&Z+d+e e e e dd'd(d)Z,dS),zUtilities related archives. N)IterableListOptional)ZipInfo)InstallationError)BZ2_EXTENSIONSTAR_EXTENSIONS XZ_EXTENSIONSZIP_EXTENSIONS) ensure_dirzbz2 module is not availablezlzma module is not available)returncCstd}t||S)zBGet the current umask which involves having to set it temporarily.r)osumask)maskrK/opt/hc_python/lib/python3.8/site-packages/pip/_internal/utils/unpacking.py current_umask,s  r)pathr cCsh|dd}d|krHd|kr4|d|dksd}n8trRd}n$drfd}ntdd }tj|d d }zt d d | D}z tj Wn"t k rt||YnXt|r| D]<}t|j\}}||_|rt|j\}} ||kr| |_qtjttjdfdd } |j| dW5| XdS)a Untar the file (with path `filename`) to the destination `location`. All files are written based on system defaults and umask (i.e. permissions are not preserved), except that regular file members with any execute permissions (user, group, or world) have "chmod +x" applied on top of the default. Note that for windows, any execute changes using os.chmod are no-ops per the python docs. z.gzz.tgzzr:gzzr:bz2zr:xzz.tarrz-Cannot determine compression type for file %szr:*zutf-8)encodingcSsg|] }|jqSr)rJ).0memberrrr szuntar_file..)rTrr c s|j}zLz|}Wn8tjk rNtjdddkrHt|}nYnXWn8tjk r}zd}t||W5d}~XYnX| r|d@r|_nd|_|S)N>rVrV rYrV rV z%Invalid member in the tar file {}: {}r)) r3tarfileLinkOutsideDestinationErrorsys version_info tar_filterTarErrorrrCisfile)rTr orig_modeexcrM data_filterdefault_mode_plus_executabler5r6rr pip_filters(  zuntar_file..pip_filter)filterN)r lowerrDrr loggerwarningrbr;r<r! getmembersrlAttributeError_untar_without_filterr*rrJislnklinknameTarInfostr extractall) r5r6r3tarrIrT name_lead name_restlnk_leadlnk_restrnrrkr untar_filesB    (r)r5r6r{rIr c Csz|D]j}|j}|r$t|d}tj||}t||sRd}t||||| rdt |q| rz| ||Wn<t k r}ztd||j|WYqW5d}~XYnXqz||} WnBttfk r }ztd||j|WYqW5d}~XYnXt tj|| dk s,tt|d} t| | W5QRX| ||||jd@rt|qdS)z/Fallback for Python without tarfile.data_filterrzQThe tar file ({}) has a file ({}) trying to install outside target directory ({})z/In the tar file %s the member %s is invalid: %sNr:r))rsrJrr rrAr(rrCisdirr issym_extract_member Exceptionrqrr extractfileKeyErrorrtrBAssertionErrorr;rErFr<utimer3r,) r5r6r{rIrTrKrrMrjrNrOrrrrusP      ru)r5r6 content_typer cCstj|}|dks,|ts,t|rDt|||d dnR|dkslt |sl|t t t rxt||ntd|||td|dS)Nzapplication/zipz.whl)r7zapplication/x-gzipzZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz#Cannot determine archive format of )r rrealpathrprDr r= is_zipfilerPrb is_tarfilerrr rrqcriticalr)r5r6rrrr unpack_file5s,   r)T)N)-__doc__loggingr rEr1rdrbr=typingrrrrpip._internal.exceptionsrpip._internal.utils.filetypesrrr r pip._internal.utils.miscr getLogger__name__rqSUPPORTED_EXTENSIONSbz2 ImportErrordebuglzmaintrryrr0r!r(r*r,r4rPrTarFilerurrrrrs\        .b =