U .e%@sXdZddlmZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z m Z mZmZddlmZddlmZerddlmZmZmZmZmZeeZee ZzddlZee 7ZWnek re d YnXzddl!Z!ee7ZWn ek re d YnXd d Z"d dZ#ddZ$ddZ%dddZ&ddZ'dddZ(dS)zUtilities related archives. )absolute_importN)InstallationError)BZ2_EXTENSIONSTAR_EXTENSIONS XZ_EXTENSIONSZIP_EXTENSIONS) ensure_dir)MYPY_CHECK_RUNNING)IterableListOptionalTextUnionzbz2 module is not availablezlzma module is not availablecCstd}t||S)zBGet the current umask which involves having to set it temporarily.r)osumask)maskrA/usr/lib/python3.8/site-packages/pip/_internal/utils/unpacking.py current_umask2s  rcCsh|dd}d|krHd|kr4|d|dksd}n8|trRd}n$|drfd}ntd|d }t||}zt d d | D}| D]}|j }|rt |d }tj||}t||sd }t||||zt|j|d|Wntjk rYnX|r4t|q|rz|||Wn>tk r} ztd||j | WYqW5d} ~ XYnXqz||} WnBttfk r} ztd||j | WYqW5d} ~ XYnXttj|t|d} t | | W5QRX| |!|||j"d@rt#|dt$dBqW5| 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 after being written. 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:*cSsg|] }|jqSrr=).0memberrrr szuntar_file..rzQThe tar file ({}) has a file ({}) trying to install outside target directory ({})rFz/In the tar file %s the member %s is invalid: %sNr*r(r))%rlowerr2rrloggerZwarningtarfiler+r,r!Z getmembersr=rrrr/r%rr1Z data_filterreplaceZLinkOutsideDestinationErrorisdirZissymZ_extract_member ExceptionZ extractfileKeyErrorAttributeErrorr0r6r7utimerBr5r) r.r8rBZtarr;rHr>rr@excrArCrrr untar_files           rTcCstj|}|dks,|ts,t|rDt|||d dnR|dkslt |sl|t t t rxt||ntd|||td|dS)Nzapplication/zipz.whl)r9zapplication/x-gzipzZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz%Cannot determine archive format of {})rrrealpathrJr2rr-Z is_zipfilerDrLZ is_tarfilerrrrTrKZcriticalrr1)r.r8Z content_typerrr unpack_files<     rV)T)N))__doc__Z __future__rZloggingrr6r3rLr-Zpip._internal.exceptionsrZpip._internal.utils.filetypesrrrrZpip._internal.utils.miscrZpip._internal.utils.typingr typingr r r r rZ getLogger__name__rKZSUPPORTED_EXTENSIONSbz2 ImportErrordebugZlzmarrr!r%rDrTrVrrrrsB        4^