
    4Քh.                       S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
Jr  SSK	Jr  SSKJr  SSKJrJrJrJr  SSKJr  \R,                  " \5      r\\-   r SSKr\\-  r SSKr\\-  rSS jrSS jrSS jr SS jr!SS jr"SS jr#SS jr$SSS jjr%SS jr&          SS jr' S        S!S jjr(g! \ a    \R9                  S	5         Nqf = f! \ a    \R9                  S
5         Nf = f)"zUtilities related archives.    )annotationsN)Iterable)ZipInfo)InstallationError)BZ2_EXTENSIONSTAR_EXTENSIONSXZ_EXTENSIONSZIP_EXTENSIONS)
ensure_dirzbz2 module is not availablezlzma module is not availablec                 ^    [         R                  " S5      n [         R                  " U 5        U $ )zBGet the current umask which involves having to set it temporarily.r   )osumask)masks    U/var/www/auris/envauris/lib/python3.13/site-packages/pip/_internal/utils/unpacking.pycurrent_umaskr   -   s    88A;DHHTNK    c                
   U R                  S5      R                  S5      n SU ;   aB  SU ;   a$  U R                  S5      U R                  S5      :  d  SU ;  a  U R                  SS5      $ SU ;   a  U R                  SS5      $ U S/$ )N/\    )lstripfindsplitpaths    r   split_leading_dirr   4   sz    ;;s""4(D
d{	$))C.499T?:t4?Ozz#q!!	zz$""bzr   c                b    SnU  H'  n[        U5      u  p4U(       d    gUc  UnM   X1:w  d  M'    g   g)zuReturns 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_prefixr   prefixrests        r   has_leading_dirr#   @   s>     M(.""M$  r   c                    [         R                  R                  U 5      n[         R                  R                  U5      n[         R                  R                  X#/5      nXB:H  $ )zD
Return true if the absolute path of target is within the directory
)r   r   abspathcommonprefix)	directorytargetabs_directory
abs_targetr!   s        r   is_within_directoryr+   O   sH     GGOOI.M(JWW!!="=>F""r   c                 $    S[        5       ) -  S-  $ )Ni  I   )r    r   r   !_get_default_mode_plus_executabler/   Z   s    MO##e++r   c                B    [         R                  " U [        5       5        g)zl
Make file present at path have execute for user/group/world
(chmod +x) is no-op on windows per python docs
N)r   chmodr/   r   s    r   2set_extracted_file_to_default_mode_plus_executabler2   ^   s    
 HHT467r   c                    U R                   S-	  n[        U=(       a"    [        R                  " U5      =(       a    US-  5      $ )N   r-   )external_attrboolstatS_ISREG)infomodes     r   zip_item_is_executabler;   f   s6    #D <d+<u==r   c                   [        U5        [        U S5      n [        R                  " USS9n[	        UR                  5       5      =(       a    UnUR                  5        GH+  nUR                  nUnU(       a  [        U5      S   n[        R                  R                  X5      n[        R                  R                  U5      n	[        X5      (       d  Sn
[        U
R                  XU5      5      eUR!                  S5      (       a  [        U5        M  [        U	5        UR                  U5      n [        US5       n["        R$                  " X5        SSS5        UR'                  5         [)        U5      (       a  [+        U5        GM+  GM.     UR'                  5         g! , (       d  f       NR= f! UR'                  5         [)        U5      (       a  [+        U5        f f = f! UR'                  5         f = f)	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)
allowZip64r   zQThe zip file ({}) has a file ({}) trying to install outside target directory ({}))r   r   wbN)r   openzipfileZipFiler#   namelistinfolistfilenamer   r   r   joindirnamer+   r   formatendswithshutilcopyfileobjcloser;   r2   )rE   locationflattenzipfpzipleadingr9   namefndirmessagefpdestfps                r   
unzip_filerX   m   sy    x4 E ooe5!#,,.1=gLLND==DB&t,Q/h+B''//"%C&x444  (xX(NOO{{;''23 XXd^Ob$6**26 ( HHJ-d33J2N 45 #: 	 ( HHJ-d33J2N 4 	s<   DG# 2F2>F!F23G# !
F/	+F22.G  G# #G5c                \  ^ ^^^ [        T5        T R                  5       R                  S5      (       d$  T R                  5       R                  S5      (       a  SnOT R                  5       R                  [        5      (       a  SnOjT R                  5       R                  [        5      (       a  SnO?T R                  5       R                  S5      (       a  SnO[
        R                  ST 5        S	n[        R                  " T US
S9n [        UR                  5        Vs/ s H  oDR                  PM     sn5      n [        R                  m[        5       mU(       ao  UR                  5        H[  n[        UR                  5      u  pgXtl        UR                  5       (       d  M7  [        UR                   5      u  pX:X  d  MU  Xl        M]     SUUU U4S jjn
UR#                  TU
S9  UR)                  5         gs  snf ! [$         a    ['        T TX55         N/f = f! UR)                  5         f = f)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.tgzzr:gzzr:bz2zr:xzz.tarrz-Cannot determine compression type for file %szr:*zutf-8)encodingc                  > U R                   n  T" U T5      n U R                  5       (       a  US-  (       a	  TU l         U $ S U l         U $ ! [        R                   a2    [        R                  S S S;   a  [        R
                  " U T5      n  Nue f = f! [        R                   a"  nSn[        UR                  TU5      5      eS nAff = f)N   >   r]   	      r]   
      r]         z%Invalid member in the tar file {}: {}r-   )
r:   tarfileLinkOutsideDestinationErrorsysversion_info
tar_filterTarErrorr   rH   isfile)	memberr   	orig_modeexcrU   data_filterdefault_mode_plus_executablerE   rM   s	        r   
pip_filteruntar_file.<locals>.pip_filter   s    "KK	"!,VX!>2 ==??y5'8">FK  #'FKA #>> "++BQ/ 4  &-%7%7%IF!" '' 	EG ,$ 		s0   	A
 
ABB BB C	'CC	)filterN)rn   tarfile.TarInfor   strreturnrv   )r   lowerrI   r   r	   loggerwarningrg   r@   r#   
getmembersrR   rq   r/   r   islnklinkname
extractallAttributeError_untar_without_filterrL   )rE   rM   r:   tarrn   rQ   	name_lead	name_restlnk_leadlnk_restrs   rq   rr   s   ``         @@r   
untar_filer      s    x~~  ''8>>+;+D+DV+L+L			"	">	2	2			"	"=	1	1			"	"6	*	*;	
 
,,x
8CC!S^^=M"N=M6;;=M"NO
:	8!--K ,M+N( "nn.F+<V[[+I(I"+K||~~->v-O*#0.6O /% %N NN8JN7 			E #O  	D!(HcC	Dv 			sO   H G73H ;G< AH #H %H 7H <HH HH H+c                   UR                  5        GHi  nUR                  nU(       a  [        U5      S   n[        R                  R                  X5      n[        X5      (       d  Sn[        UR                  XU5      5      eUR                  5       (       a  [        U5        M  UR                  5       (       a   UR                  XF5        M   UR!                  U5      n	[        [        R                  R'                  U5      5        U	c   e[)        US5       n
[*        R,                  " X5        SSS5        U	R/                  5         UR1                  XF5        UR2                  S-  (       d  GM^  [5        U5        GMl     g! [         a.  n[        R                  SU UR                  U5         SnAGM  SnAff = f! ["        [$        4 a.  n[        R                  SU UR                  U5         SnAGM  SnAff = f! , (       d  f       N= f)z/Fallback for Python without tarfile.data_filterr   zQThe tar file ({}) has a file ({}) trying to install outside target directory ({})z/In the tar file %s the member %s is invalid: %sNr?   r-   )r|   rR   r   r   r   rF   r+   r   rH   isdirr   issym_extract_member	Exceptionrz   r{   extractfileKeyErrorr   rG   r@   rJ   rK   rL   utimer:   r2   )rE   rM   r   rQ   rn   rS   r   rU   rp   rV   rW   s              r   r   r      s    .."[["2&q)Bww||H)"8220  $GNN88$LMM<<>>t\\^^##F1__V, rwwt,->!>dD!V""2. "HHJIIf#{{U""B4Ha #   	 EKK	 	 n- 	 EKK	 	 "!s<   :F F;G< 
F8
"F33F8;G9"G44G9<
H
	c                "   [         R                  R                  U 5      n US:X  dC  U R                  5       R	                  [
        5      (       d  [        R                  " U 5      (       a  [        XU R	                  S5      (       + S9  g US:X  dQ  [        R                  " U 5      (       d6  U R                  5       R	                  [        [        -   [        -   5      (       a  [        X5        g [        R!                  SU UU5        [#        SU 35      e)Nzapplication/zipz.whl)rN   zapplication/x-gzipzZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz#Cannot determine archive format of )r   r   realpathry   rI   r
   rA   
is_zipfilerX   rg   
is_tarfiler   r   r	   r   rz   criticalr   )rE   rM   content_types      r   unpack_filer   5  s    
 ww)H))>>$$^44h''883D3DV3L/LM,,h''>>$$^n%D}%TUU8& 	+	
  "EhZ PQQr   )rx   int)r   rw   rx   z	list[str])r   zIterable[str]rx   r6   )r'   rw   r(   rw   rx   r6   )r   rw   rx   None)r9   r   rx   r6   )T)rE   rw   rM   rw   rN   r6   rx   r   )rE   rw   rM   rw   rx   r   )
rE   rw   rM   rw   r   ztarfile.TarFilerQ   r6   rx   r   )N)rE   rw   rM   rw   r   z
str | Nonerx   r   ))__doc__
__future__r   loggingr   rJ   r7   ri   rg   rA   collections.abcr   r   pip._internal.exceptionsr   pip._internal.utils.filetypesr   r   r	   r
   pip._internal.utils.miscr   	getLogger__name__rz   SUPPORTED_EXTENSIONSbz2ImportErrordebuglzmar   r   r#   r+   r/   r2   r;   rX   r   r   r   r.   r   r   <module>r      sT   ! "  	   
   $  6  0			8	$ &6 0N*1M)
	#,8>+\]@7I7I7I 
7I 	7I
 
7Iz  $RRR R 
	Ri  0
LL./0  1
LL/01s$   !	C +	C CCC98C9