U ʗReu"@sdZddlZddlZddlZddlZddlZddlZddlmZm Z m Z ddlm Z ddl m Z ddlmZmZmZmZddlmZeeZeeZzddlZee7ZWnek redYnXzddlZee7ZWnek red YnXed d d Zee ed ddZ eee!dddZ"eee!dddZ#edd ddZ$e e!dddZ%d%eee!ddddZ&eeddd d!Z'd&eee edd"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)maskr/builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/utils/unpacking.py current_umask+s  r)pathr cCsh|dd}d|krHd|kr4|d|dkss r!) directorytargetr cCs0tj|}tj|}tj||g}||kS)zL Return true if the absolute path of target is within the directory )r rabspath commonprefix)r"r# abs_directory abs_targetrrrris_within_directoryMs  r(cCst|dt@dBdS)zx Make file present at path have execute for user/group/world (chmod +x) is no-op on windows per python docs iIN)r chmodrrrrr2set_extracted_file_to_default_mode_plus_executableXsr+)infor cCs$|jd?}t|o t|o |d@S)Nr)) external_attrboolstatS_ISREG)r,moderrrzip_item_is_executable`s r3T)filenamelocationflattenr c Cst|t|d}ztj|dd}t|o0|}|D]}|j}|}|rXt |d}t j ||}t j |} t||sd} t| ||||ds|drt|q:t| ||} z&t|d} t| | W5QRXW5| t|rt|Xq:W5|Xd S) a Unzip 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. rbT) allowZip64rzQThe zip file ({}) has a file ({}) trying to install outside target directory ({})rrwbN)r openclosezipfileZipFiler!namelistinfolistr4rr rjoindirnamer(rformatendswithr3r+shutil copyfileobj) r4r5r6zipfpzipleadingr,namefndirmessagefpdestfprrr unzip_filegs6          rO)r4r5r c Cs.t||ds$|dr*d}nL|tr>d}n8|trRd}n$|drfd}ntd|d }tj||d d }zt d d | D}| D]p}|j }|rt |d}tj||}t||sd}t|||||rt|q|rbz|||Wn>tk r^} ztd||j | WYqW5d} ~ XYnXqz||} WnBttfk r} ztd||j | WYqW5d} ~ XYnXttj|| dk stt|d} t| | W5QRX| ||||j d@rt!|qW5| 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:*zutf-8)encodingcSsg|] }|jqSr)rI).0memberrrr szuntar_file..rzQThe tar file ({}) has a file ({}) trying to install outside target directory ({})z/In the tar file %s the member %s is invalid: %sNr9r))"r lowerrCrr loggerwarningtarfiler:r;r! getmembersrIrr rr@r(rrBisdirissym_extract_member Exception extractfileKeyErrorAttributeErrorrAAssertionErrorrDrEutimer2r+) r4r5r2tarrHrSrJrrLexcrMrNrrr untar_filest         re)r4r5 content_typer cCstj|}|dks,|ts,t|rDt|||d dnR|dkslt |sl|t t t rxt||ntd|||td|dS)Nzapplication/zipz.whl)r6zapplication/x-gzipzZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz#Cannot determine archive format of )r rrealpathrUrCr r< is_zipfilerOrX is_tarfilerrr rerVcriticalr)r4r5rfrrr unpack_files,   rk)T)N))__doc__loggingr rDr0rXr<typingrrrrpip._internal.exceptionsrpip._internal.utils.filetypesrrr r pip._internal.utils.miscr getLogger__name__rVSUPPORTED_EXTENSIONSbz2 ImportErrordebuglzmaintrstrrr/r!r(r+r3rOrerkrrrrsL        .S