
    'j9                       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.       SS j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 jr( S$       S%S jjr)g! \ a    \R9                  S	5         Nf = 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/html/KUNJ/venv/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   Fresolve_symlinksc               d   U(       a?  [         R                  R                  U 5      n[         R                  R                  U5      nO>[         R                  R                  U 5      n[         R                  R                  U5      nXC:H  =(       d"    UR	                  U[         R
                  -   5      $ )a  
Return true if the absolute path of target is within the directory
(including when target is equal to the directory).

When ``resolve_symlinks`` is true, resolve symlinks before comparing so
traversal through a symlink (e.g. "link/../file") is also caught.
)r   r   realpathabspath
startswithsep)	directorytargetr%   abs_directory
abs_targets        r   is_within_directoryr/   O   sx     ((3WW%%f-
	2WW__V,
&W**?*?PRPVPV@V*WWr   c                 $    S[        5       ) -  S-  $ )Ni  I   )r    r   r   !_get_default_mode_plus_executabler3   c   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   chmodr3   r   s    r   2set_extracted_file_to_default_mode_plus_executabler6   g   s    
 HHT467r   c                    U R                   S-	  n[        U=(       a"    [        R                  " U5      =(       a    US-  5      $ )N   r1   )external_attrboolstatS_ISREG)infomodes     r   zip_item_is_executabler?   o   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?   r6   )rI   locationflattenzipfpzipleadingr=   namefndirmessagefpdestfps                r   
unzip_filer\   v   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   >   ra   	      ra   
      ra         z%Invalid member in the tar file {}: {}r1   )
r>   tarfileLinkOutsideDestinationErrorsysversion_info
tar_filterTarErrorr   rL   isfile)	memberr   	orig_modeexcrY   data_filterdefault_mode_plus_executablerI   rQ   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)rr   tarfile.TarInfor   strreturnrz   )r   lowerrM   r   r	   loggerwarningrk   rD   r#   
getmembersrV   ru   r3   r   islnklinkname
extractallAttributeError_untar_without_filterrP   )rI   rQ   r>   tarrr   rU   	name_lead	name_restlnk_leadlnk_restrw   ru   rv   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                L   [         R                  R                  [         R                  R                  UR                  5      UR
                  5      n[         R                  R                  U5      nUR                  SS5      n U R                  U5        g! [         a     gf = f)zGCheck if the file pointed to by the symbolic link is in the tar archiver   r   TF)
r   r   rJ   rK   rV   r   normpathreplace	getmemberKeyError)r   tarinfor   s      r   is_symlink_target_in_tarr     sy    ww||BGGOOGLL97;K;KLHww)Hc*Hh s   B 
B#"B#c                   UR                  5        GHA  nUR                  nU(       a  [        U5      S   n[        R                  R                  X5      n[        X5      (       a  [        XSS9(       d  Sn[        UR                  XU5      5      eUR                  5       (       a  [        U5        M  UR                  5       (       a  [        R                  R                  [        R                  R                  U5      UR                  5      n[        XSS9(       d1  Sn[        UR                  XR                  UR                  5      5      e[        X$5      (       d1  Sn[        UR                  XR                  UR                  5      5      e UR                  XF5        GM   UR'                  U5      n
[        [        R                  R                  U5      5        U
c   e[-        US5       n[.        R0                  " X5        SSS5        U
R3                  5         UR5                  XF5        UR6                  S-  (       d  GM6  [9        U5        GMD     g! [          a.  n	["        R%                  SU UR                  U	5         Sn	A	GMz  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   Tr$   zQThe tar file ({}) has a file ({}) trying to install outside target directory ({})z/In the tar file %s the member %s is invalid: %sNrC   r1   )r   rV   r   r   r   rJ   r/   r   rL   isdirr   issymrK   r   r   _extract_member	Exceptionr~   r   extractfiler   r   rD   rN   rO   rP   utimer>   r6   )rI   rQ   r   rU   rr   rW   r   rY   r,   rt   rZ   r[   s               r   r   r     sC    .."[["2&q)Bww||H)
 #822:MT;
0  $GNN88$LMM<<>>t\\^^ WW\\"''//$"7IF&x$O4  (NN8[[&//J  ,C884  (NN8[[&//J ##F1__V, rwwt,->!>dD!V""2. "HHJIIf#{{U""B4HS #R  	 EKK	 	 n- 	 EKK	 	 "!s<   I&J0K
J""JJK#"KK
K"	c                  ^ ^^ [         R                  R                  T 5      m T R                  S5      (       + mS	U UU4S jjnS	U U4S jjnUS:X  a  U" 5       $ US:X  a  U" 5       $ T R	                  5       R                  [
        5      (       a  U" 5       $ T R	                  5       R                  [        [        -   [        -   5      (       a  U" 5       $ [        R                  " T 5      n[        R                  " T 5      nU(       a  U(       d  U" 5       $ U(       a  U(       d  U" 5       $ U(       a  U(       a  [        R                  ST 5        [        R                  ST TU5        [!        ST 35      e)
zUnpack ``filename`` into ``location``.

Archive format is chosen in order of decreasing reliability:
``content_type``, then filename extension, then magic signature
(unambiguous matches only).
z.whlc                    > [        T TTS9  g )N)rR   )r\   )rI   rQ   zip_flattens   r   _unzipunpack_file.<locals>._unzipv  s    8X{;r   c                    > [        T T5        g N)r   )rI   rQ   s   r   _untarunpack_file.<locals>._untary  s    8X&r   zapplication/zipzapplication/x-gzipzAmbiguous file signature in %s.zZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz#Cannot determine archive format of )r|   None)r   r   r'   rM   r}   r
   r   r   r	   rE   
is_zipfilerk   
is_tarfiler~   errorcriticalr   )rI   rQ   content_typer   r   r   r   r   s   ``     @r   unpack_filer   h  s'    ww)H''//K< <' ' ((x++x~~  00x~~  .!@=!PQQx ##H-J##H-J*x*xj6A
OO	' A(L
MMr   )r|   int)r   r{   r|   z	list[str])r   zIterable[str]r|   r:   )r+   r{   r,   r{   r%   r:   r|   r:   )r   r{   r|   r   )r=   r   r|   r:   )T)rI   r{   rQ   r{   rR   r:   r|   r   )rI   r{   rQ   r{   r|   r   )r   tarfile.TarFiler   rz   r|   r:   )
rI   r{   rQ   r{   r   r   rU   r:   r|   r   r   )rI   r{   rQ   r{   r   z
str | Noner|   r   )*__doc__
__future__r   loggingr   rN   r;   rm   rk   rE   collections.abcr   r   pip._internal.exceptionsr   pip._internal.utils.filetypesr   r   r	   r
   pip._internal.utils.miscr   	getLogger__name__r~   SUPPORTED_EXTENSIONSbz2ImportErrordebuglzmar   r   r#   r/   r3   r6   r?   r\   r   r   r   r   r2   r   r   <module>r      s   ! "  	   
   $  6  0			8	$ &6 0N*1M)
	  >CXXX6:X	X(,8>+\]@SISISI 
SI 	SI
 
SIr  $/N/N/N /N 
	/NO
  0
LL./0  1
LL/01s$   !	C +	C/ C,+C,/D	D	