Re%@sdZddlmZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z m Z mZmZddlmZddlmZerddlmZmZmZmZmZdd lmZejeZee ZyddlZee 7ZWne k rBej!d YnXyddl"Z"ee7ZWne k r~ej!d YnXd d Z#ddZ$ddZ%ddZ&ddZ'ddZ(dddZ)ddZ*dddZ+dS)zUtilities related archives. )absolute_importN)InstallationError)BZ2_EXTENSIONSTAR_EXTENSIONS XZ_EXTENSIONSZIP_EXTENSIONS) ensure_dir)MYPY_CHECK_RUNNING)IterableListOptionalTextUnion)ZipInfozbz2 module is not availablezlzma module is not availablecCs tjd}tj||S)zBGet the current umask which involves having to set it temporarily.r)osumask)maskr/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/unpacking.py current_umask/s rcCs|jdjd}d|krjd|krN|jd|jdksZd|krj|jddSd|kr|jddS|dgSdS)N/\)lstripfindsplit)pathrrrsplit_leading_dir7s *  rcCs\d}xO|D]G}t|\}}|s/dS|dkrD|}q ||kr dSq WdS)zyReturns true if all the paths have the same leading path name (i.e., everything is in one subdirectory in an archive)NFT)r)paths common_prefixrprefixrestrrrhas_leading_dirGs    r#cCsFtjj|}tjj|}tjj||g}||kS)zL Return true if the absolute path of target is within the directory )rrabspath commonprefix) directorytarget abs_directory abs_targetr!rrris_within_directoryWsr*cCs tj|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)rchmodr)rrrr2set_extracted_file_to_default_mode_plus_executablecsr-cCs0|jd?}t|o,tj|o,|d@S)Nr+) external_attrboolstatS_ISREG)infomoderrrzip_item_is_executablels r5Tc Cst|t|d}zYtj|dd}t|joF|}x%|jD]}|j}|}|rt|d}t j j ||}t j j |} t ||sd} t| j||||jds|jdrt|qVt| |j|} z-t|d} tj| | Wd QRXWd | jt|rlt|XqVWWd |jXd 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. rb allowZip64TrzQThe zip file ({}) has a file ({}) trying to install outside target directory ({})rrwbN)ropenzipfileZipFiler#namelistinfolistfilenamerrrjoindirnamer*rformatendswithshutil copyfileobjcloser5r-) r>locationflattenzipfpzipleadingr3namefndirmessagefpdestfprrr unzip_filets4      rQc Cst||jjds4|jjdr=d}np|jjtr[d}nR|jjtryd}n4|jjdrd}ntjd|d }tj||}zt d d |j D}x|j D]}|j }|rt |d }t jj||}t||sXd }t|j||||jrqt|q|jry|j||Wqtk r} z!tjd||j | wWYdd} ~ XqXqy|j|} WnGttfk r4} z!tjd||j | wWYdd} ~ XnXtt jj|| dk s]tt|d} tj| | WdQRX| j|j|||j d@rt!|qWWd|jXdS)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|]}|jqSr)rK).0memberrrr s zuntar_file..rzQThe tar file ({}) has a file ({}) trying to install outside target directory ({})z/In the tar file %s the member %s is invalid: %sNr8r+)"rlowerrBrrloggerwarningtarfiler9r# getmembersrKrrrr?r*rrAisdirissym_extract_member Exception extractfileKeyErrorAttributeErrorr@AssertionErrorrCrDrEutimer4r-) r>rFr4tarrJrTrLrrNexcrOrPrrr untar_filesf *           rfcCstjj|}|dksB|jjtsBtj|rbt||d|jd ns|dkst j |s|jjt t t rt||n+tjd|||tdj|dS)Nzapplication/ziprGz.whlzapplication/x-gzipzZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz%Cannot determine archive format of {})rrrealpathrVrBrr: is_zipfilerQrY is_tarfilerrrrfrWcriticalrrA)r>rF content_typerrr unpack_files$    rl),__doc__ __future__rloggingrrCr1rYr:pip._internal.exceptionsrpip._internal.utils.filetypesrrrrpip._internal.utils.miscrpip._internal.utils.typingr typingr r r r rr getLogger__name__rWSUPPORTED_EXTENSIONSbz2 ImportErrordebuglzmarrr#r*r-r5rQrfrlrrrrsF      "(         / V