7iu" dZddlZddlZddlZddlZddlZddlZddlmZm Z m Z ddlm Z ddl m Z ddlmZmZmZmZddlmZej*eZeezZ ddlZeez Z ddlZeez Zd efd Zd ed e efd Z deed e!fdZ"deded e!fdZ#d ed dfdZ$de d e!fdZ%ddedede!d dfdZ&deded dfdZ' ddedede ed dfdZ(y#e$rej7dYwxYw#e$rej7d YwxYw)zUtilities related archives. N)IterableListOptional)ZipInfo)InstallationError)BZ2_EXTENSIONSTAR_EXTENSIONS XZ_EXTENSIONSZIP_EXTENSIONS) ensure_dirzbz2 module is not availablezlzma module is not availablereturncZtjd}tj||S)zBGet the current umask which involves having to set it temporarily.r)osumask)masks f/mnt/ssd/data/python-lab/ChefSystem/venv/lib/python3.12/site-packages/pip/_internal/utils/unpacking.py current_umaskr+s 88A;DHHTN Kpathc|jdjd}d|vr=d|vr#|jd|jdksd|vr|jddSd|vr|jddS|dgS)N/\)lstripfindsplitrs rsplit_leading_dirr2sz ;;s  " "4 (D d{ $))C.499T?:t4?Ozz#q!! zz$""bzrpathscRd}|D] }t|\}}|sy||}||k7s yy)zyReturns true if all the paths have the same leading path name (i.e., everything is in one subdirectory in an archive)NFT)r)r common_prefixrprefixrests rhas_leading_dirr%>sGM(.   ""M } $ r directorytargetctjj|}tjj|}tjj||g}||k(S)zL Return true if the absolute path of target is within the directory )rrabspath commonprefix)r&r' abs_directory abs_targetr#s ris_within_directoryr-MsLGGOOI.M(J WW ! !=*"= >F ] ""rcNtj|dtzdzy)zx Make file present at path have execute for user/group/world (chmod +x) is no-op on windows per python docs iIN)rchmodrrs r2set_extracted_file_to_default_mode_plus_executabler1Xs! HHTE]_,,u46rinfocr|jdz }t|xrtj|xr|dzS)Nr/) external_attrboolstatS_ISREG)r2modes rzip_item_is_executabler:`s6    #D <d+<u ==rfilenamelocationflattenct|t|d} tj|d}t |j xr|}|j D](}|j}|}|rt|d}tjj||}tjj|} t||sd} t| j||||j!ds|j!dr t|t| |j|} t|d5} t#j$| | d d d | j't)|st+|+ |j'y #1swYFxYw#| j't)|r t+|wwxYw#|j'wxYw) 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 openzipfileZipFiler%namelistinfolistr;rrrjoindirnamer-rformatendswithshutil copyfileobjcloser:r1) r;r<r=zipfpzipleadingr2namefndirmessagefpdestfps r unzip_filerWgsx 4 E ooe5!#,,.1=gLLN OD==DB&t,Q/h+B''//"%C&x44(xX(NOO{{32;;t#423XXd^Ob$76**2v67HHJ-d3J2N7 O:  77HHJ-d3J2N4  sBDG3 F'?FF'G;GF$ F'')GGG%cbt||jjds|jjdrd}n|jjtrd}n`|jjtrd}n:|jjdrd}nt j d|d }tj||d } t|jDcgc]}|jc}}|jD]P}|j}|rt|d }tjj||}t!||sd }t#|j%||||j'r t||j)r |j+|| |j/|} ttjj5|| Jt|d5} t7j8| | ddd| j;|j=|||j>dzsFtA|S |j;ycc}w#t,$r-} t j d||j| Yd} ~ d} ~ wwxYw#t0t2f$r-} t j d||j| Yd} ~ d} ~ wwxYw#1swYxYw#|j;wxYw)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)encodingrzQThe tar file ({}) has a file ({}) trying to install outside target directory ({})z/In the tar file %s the member %s is invalid: %sNrAr/)!r lowerrJrr loggerwarningtarfilerBr% getmembersrQrrrrGr-rrIisdirissym_extract_member Exception extractfileKeyErrorAttributeErrorrHrKrLrMutimer9r1) r;r<r9tarmemberrPrRrrTexcrUrVs r untar_filerksx~~  '8>>+;+D+DV+L   " "> 2   " "= 1   " "6 * ;   ,,x 8C4!S^^=M"N66;;"NOnn&0 MFB&r*1-77<<"-D&x64(xx(PQQ||~4  ''5 0B277??401~%~$%3&&r623  &$';;&FtLa0 Md g#O"! NNI     !.1 NNI     33 s,LJB-LJLK)8L!L89L3LL K!"K L KLL  "LLL  LL LL. content_typectjj|}|dk(s8|jj t st j|rt|||j d y|dk(sFtj|s1|jj ttztzr t||ytj!d|||t#d|)Nzapplication/zipz.whl)r=zapplication/x-gzipzZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz#Cannot determine archive format of )rrrealpathr[rJr rC is_zipfilerWr^ is_tarfiler rr rkr\criticalr)r;r<rls r unpack_filerrs ww)H)) >>  $ $^ 4   h '8X83D3DV3L/LM,,   h ' >>  $ $^n%D}%T U8X&  +      "EhZ PQQr)T)N))__doc__loggingrrKr7r^rCtypingrrrrpip._internal.exceptionsrpip._internal.utils.filetypesrr r r pip._internal.utils.miscr getLogger__name__r\SUPPORTED_EXTENSIONSbz2 ImportErrordebuglzmaintrstrrr6r%r-r1r:rWrkrrrrrs ++6 0   8 $&60N*1M) s C DI  8C= T #3###7S7T7>>T>+++d+d+\MMMMf#'RRR3-R RM0 LL./01 LL/01s$ C % C) C&%C&)DD