
    жvg.              
       h   d Z ddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZmZmZmZ ddlmZ  ej        e          Zeez   Z	 ddlZeez  Zn # e$ r e                    d           Y nw xY w	 ddlZeez  Zn # e$ r e                    d	           Y nw xY wd
efdZde d
e
e          fdZ!de	e          d
e"fdZ#de de d
e"fdZ$d
efdZ%de d
dfdZ&ded
e"fdZ'd"de de de"d
dfdZ(de de d
dfdZ)de de dej*        de"d
df
dZ+	 d#de de d ee          d
dfd!Z,dS )$zUtilities related archives.
    N)IterableListOptional)ZipInfo)InstallationError)BZ2_EXTENSIONSTAR_EXTENSIONSXZ_EXTENSIONSZIP_EXTENSIONS)
ensure_dirzbz2 module is not availablezlzma module is not availablereturnc                  V    t          j        d          } t          j        |            | S )zBGet the current umask which involves having to set it temporarily.r   )osumask)masks    Z/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/pip/_internal/utils/unpacking.pycurrent_umaskr   ,   s!    8A;;DHTNNNK    pathc                 *   |                      d                               d          } d| v rJd| v r,|                     d          |                     d          k     sd| vr|                     dd          S d| v r|                     dd          S | dgS )N/\    )lstripfindsplitr   s    r   split_leading_dirr   3   s    ;;s""4((D
d{{	$))C..499T??::t4?O?Ozz#q!!!	zz$"""bzr   pathsc                 ^    d}| D ]'}t          |          \  }}|s dS ||}||k    r dS (dS )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_prefixr   prefixrests        r   has_leading_dirr%   ?   sa     M  (.. 	55""MM}$$55 %4r   	directorytargetc                     t           j                            |           }t           j                            |          }t           j                            ||g          }||k    S )zL
    Return true if the absolute path of target is within the directory
    )r   r   abspathcommonprefix)r&   r'   abs_directory
abs_targetr#   s        r   is_within_directoryr-   N   sO     GOOI..M((JW!!=*"=>>F]""r   c                  ,    dt                       z  dz  S )Ni  I   )r    r   r   !_get_default_mode_plus_executabler1   Y   s    MOO##e++r   c                 H    t          j        | t                                 dS )zx
    Make file present at path have execute for user/group/world
    (chmod +x) is no-op on windows per python docs
    N)r   chmodr1   r   s    r   2set_extracted_file_to_default_mode_plus_executabler4   ]   s#    
 HT46677777r   infoc                 f    | j         dz	  }t          |ot          j        |          o|dz            S )N   r/   )external_attrboolstatS_ISREG)r5   modes     r   zip_item_is_executabler=   e   s7    #D <d++<u===r   Tfilenamelocationflattenc                 |   t          |           t          | d          }	 t          j        |d          }t	          |                                          o|}|                                D ]}|j        }|}|rt          |          d         }t          j
                            ||          }t          j
                            |          }	t          ||          s&d}
t          |
                    | ||                    |                    d          s|                    d          rt          |           t          |	           |                    |          }	 t          |d          5 }t#          j        ||           d	d	d	           n# 1 swxY w Y   |                                 t)          |          rt+          |           h# |                                 t)          |          rt+          |           w w xY w	 |                                 d	S # |                                 w xY w)
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infolistr>   r   r   r   joindirnamer-   r   formatendswithshutilcopyfileobjcloser=   r4   )r>   r?   r@   zipfpzipleadingr5   namefndirmessagefpdestfps                r   
unzip_filerZ   l   sX    x4  E oe555!#,,..11=gLLNN 	O 	OD=DB 0&t,,Q/h++B'//"%%C&x44 P4  (xX(N(NOOO{{3 O2;;t#4#4 O23 XXd^^Ob$ 76*2v6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 HHJJJ-d33 OJ2NNN HHJJJ-d33 OJ2NNNNO5	O: 	sH   EH% %G5FGF	GF	G"4H% 5HH% %H;c                     t                                                                          d          s'                                                     d          rd}n                                                     t                    rd}nv                                                     t                    rd}nG                                                     d          rd}nt
                              d            d	}t          j         |d
          }	 t          d |
                                D                       }	 t          j        t                      |rm|
                                D ]X}t          |j                  \  }}||_        |                                r$t          |j                  \  }}	||k    r|	|_        Ydt          j        dt$          dt          j        f fd}
|                    |
           n"# t(          $ r t+           ||           Y nw xY w|                                 dS # |                                 w xY w)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                     g | ]	}|j         
S r0   )rT   ).0members     r   
<listcomp>zuntar_file.<locals>.<listcomp>   s    "N"N"N66;"N"N"Nr   r`   r   r   c                    | j         }	 	  |           } nB# t          j        $ r0 t          j        d d         dv rt          j        |           } n Y nw xY wn<# t          j        $ r*}d}t          |                    |                    d }~ww xY w| 	                                r|dz  r| _         nd | _         | S )N   >   rc         rc   	   rf   rc   
      rc         z%Invalid member in the tar file {}: {}r/   )
r<   tarfileLinkOutsideDestinationErrorsysversion_info
tar_filterTarErrorr   rL   isfile)	r`   r   	orig_modeexcrW   data_filterdefault_mode_plus_executabler>   r?   s	        r   
pip_filterzuntar_file.<locals>.pip_filter   s   "K	"!,VX!>!>"> " " "+BQB/ 4   &-%7%I%IFF! #F" ' 	 	 	EG ,$   		 ==?? 'y5'8 '">FKK #'FKs2    A <AA AA B*%BB)filterN)r   lowerrM   r   r
   loggerwarningro   rE   r%   
getmembersrx   r1   r   rT   islnklinknameTarInfostr
extractallAttributeError_untar_without_filterrP   )r>   r?   r<   tarrS   r`   	name_lead	name_restlnk_leadlnk_restrz   rx   ry   s   ``         @@r   
untar_filer      s    x~~  '' 8>>+;+;+D+DV+L+L 				"	">	2	2 				"	"=	1	1 					"	"6	*	* ;	
 	
 	
 
,x
8
8
8CD!"N"NS^^=M=M"N"N"NOO
;	8!-K ,M+N+N( 
7 "nn.. 7 7F+<V[+I+I(Iy"+FK||~~ 7->v-O-O*(#y00.6FO&7? &# &'/ & & & & & & & & &P NN8JN7777s  	D 	D 	D!(Hc7CCCCC	Dx 					s1   "+I H B=I H63I 5H66I I%r   rS   c                 B   |                                 D ]}|j        }|rt          |          d         }t          j                            ||          }t          ||          s&d}t          |                    | ||                    |	                                rt          |           |                                rQ	 |                    ||           # t          $ r,}t                              d| |j        |           Y d}~d}~ww xY w	 |                    |          }	nA# t"          t$          f$ r-}t                              d| |j        |           Y d}~Pd}~ww xY wt          t          j                            |                     |	J t)          |d          5 }
t+          j        |	|
           ddd           n# 1 swxY w Y   |	                                 |                    ||           |j        dz  rt5          |           
dS )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: %sNrD   r/   )r   rT   r   r   r   rJ   r-   r   rL   isdirr   issym_extract_member	Exceptionr}   r~   extractfileKeyErrorr   rK   rE   rN   rO   rP   utimer<   r4   )r>   r?   r   rS   r`   rU   r   rW   rw   rX   rY   s              r   r   r      s    .."" 0I 0I[ 	*"2&&q)Bw||Hb))"8T22 	N0  $GNN8T8$L$LMMM<<>> %	It\\^^ #	I##FD1111 	 	 	 EK	   	__V,,n- 	 	 	 EK	   	 rwt,,--->>>dD!! /V"2v.../ / / / / / / / / / / / / / /HHJJJIIfd###{U" IB4HHHa0I 0IsB   C
D&"DDD,,E*="E%%E*-GG	G	content_typec                 J   t           j                            |           } |dk    s@|                                                     t
                    st          j        |           r(t          | ||                     d                      d S |dk    sPt          j
        |           s<|                                                     t          t          z   t          z             rt          | |           d S t                              d| ||           t#          d|           )Nzapplication/zipz.whl)r@   zapplication/x-gzipzZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz#Cannot determine archive format of )r   r   realpathr|   rM   r   rF   
is_zipfilerZ   ro   
is_tarfiler	   r   r
   r   r}   criticalr   )r>   r?   r   s      r   unpack_filer   5  s&   
 w))H)))>>$$^44 	*h'' 	* 	8X83D3DV3L3L/LMMMMMM,,,h'' 	->>$$^n%D}%TUU 	- 	8X&&&&& 	+	
 	
 	
   Ph P PQQQr   )T)N)-__doc__loggingr   rN   r:   rq   ro   rF   typingr   r   r   r   pip._internal.exceptionsr   pip._internal.utils.filetypesr   r	   r
   r   pip._internal.utils.miscr   	getLogger__name__r}   SUPPORTED_EXTENSIONSbz2ImportErrordebuglzmaintr   r   r   r9   r%   r-   r1   r4   r=   rZ   r   TarFiler   r   r0   r   r   <module>r      s     				   



   + + + + + + + + + +       6 6 6 6 6 6            0 / / / / /		8	$	$ &6 0JJJN* 0 0 0
LL./////01KKKM) 1 1 1
LL/000001s    	C 	DI 	 	 	 	8C= T    #3 # # # # # #,3 , , , ,8S 8T 8 8 8 8> >T > > > >+ + + +d +d + + + +\^ ^ ^ ^ ^ ^ ^B7I7I7I 
7I 	7I
 
7I 7I 7I 7Iz #'R RRR 3-R 
	R R R R R Rs$   	A' 'BB	B B/.B/