§
    ·è×jú#  ã                   óþ   — 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	 ddl
mZ g d¢Z G d„ de¦  «        Z G d	„ d
e¦  «        Zd„ Zd„ Zedf	 dd„Zefdd„Zefdd„Zefd„Zd„ Zd„ Zefdefd„ZeeefZdS )z/Utilities for extracting common archive formatsé    Né   )Úensure_directory)ÚDistutilsError)ÚUnrecognizedFormatÚUnsafeMemberÚdefault_filterÚextraction_driversÚunpack_archiveÚunpack_directoryÚunpack_tarfileÚunpack_zipfilec                   ó   — e Zd ZdZdS )r   z#Couldn't recognize the archive typeN©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úcC:\Users\johnn\AppData\Local\Programs\Python\Python311\Lib\site-packages\setuptools/archive_util.pyr   r      s   € € € € € Ø-Ð-Ð-Ð-r   r   c                   ó   — e Zd ZdZdS )r   a  An archive member that would be extracted outside the destination

    Deliberately not an `UnrecognizedFormat`, which ``unpack_archive`` catches
    to fall through to the next driver; an unsafe member must abort the
    extraction rather than hand the archive to another driver.
    Nr   r   r   r   r   r      s   € € € € € ðð ð ð r   r   c                 ó   — |S )z@The default progress/filter callback; returns True for all filesr   )ÚsrcÚdsts     r   r   r   (   s   € à€Jr   c                 ó2  — |                      d¦  «        sd|v st          j        |¦  «        d         rt          |›d| ›�¦  «        ‚|                     d¦  «        }d|v rt          |›d| ›�¦  «        ‚t          j        j        | g|¢R Ž }t
          j                             | ¦  «        }t
          j                             |¦  «        }||k    rG|                      t
          j                             |d¦  «        ¦  «        st          |›d| ›�¦  «        ‚|S )aÅ  
    Return the path where archive member `name` belongs under `extract_dir`,
    raising `UnsafeMember` if the member would be written outside of it.

    Both the tar and zip formats specify '/' as the only path separator, so a
    backslash is never a legitimate separator in a member name and must not be
    allowed to act as one on Windows (GHSA-grgh-hr87-3jpw). Names that are
    absolute, drive-qualified, or UNC are rejected for the same reason.

    A directory member keeps its trailing separator, as callers rely on it to
    distinguish a directory from a file.

    >>> _resolve_dest('dest', 'sub/file.txt') == os.path.join('dest', 'sub', 'file.txt')
    True
    >>> _resolve_dest('dest', 'sub/dir/') == os.path.join('dest', 'sub', 'dir', '')
    True
    >>> _resolve_dest('dest', '..\\escaped.txt')
    Traceback (most recent call last):
    ...
    setuptools.archive_util.UnsafeMember: '..\\escaped.txt' would be extracted outside of 'dest'
    ú/ú\r   z would be extracted outside of z..Ú )	Ú
startswithÚntpathÚ
splitdriver   ÚsplitÚosÚpathÚjoinÚrealpath)Úextract_dirÚnameÚpartsÚdestÚrootÚresolveds         r   Ú_resolve_destr-   -   s  € ð, ‡‚�sÑÔð V˜t t˜|˜|­vÔ/@ÀÑ/FÔ/FÀqÔ/I˜|Ý˜dÐTÐTÀ[ÐTÐTÑUÔUÐUà�JŠJ�s‰OŒO€Eàˆu€}€}Ý˜dÐTÐTÀ[ÐTÐTÑUÔUÐUåŒ7Œ<˜Ð, eÐ,Ð,Ð,€Dõ Œ7×Ò˜KÑ(Ô(€DÝŒw×Ò Ñ%Ô%€HØ�4ÒÐ × 3Ò 3µB´G·L²LÀÀrÑ4JÔ4JÑ KÔ KÐÝ˜dÐTÐTÀ[ÐTÐTÑUÔUÐUà€Kr   Úreturnc                 ó~   — |pt           D ]"}	  || ||¦  «          dS # t          $ r Y Œw xY wt          d| › �¦  «        ‚)a¡  Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat``

    `progress_filter` is a function taking two arguments: a source path
    internal to the archive ('/'-separated), and a filesystem path where it
    will be extracted.  The callback must return the desired extract path
    (which may be the same as the one passed in), or else ``None`` to skip
    that file or directory.  The callback can thus be used to report on the
    progress of the extraction, as well as to filter the items extracted or
    alter their extraction paths.

    `drivers`, if supplied, must be a non-empty sequence of functions with the
    same signature as this function (minus the `drivers` argument), that raise
    ``UnrecognizedFormat`` if they do not support extracting the designated
    archive type.  The `drivers` are tried in sequence until one is found that
    does not raise an error, or until all are exhausted (in which case
    ``UnrecognizedFormat`` is raised).  If you do not supply a sequence of
    drivers, the module's ``extraction_drivers`` constant will be used, which
    means that ``unpack_zipfile`` and ``unpack_tarfile`` will be tried, in that
    order.
    NzNot a recognized archive type: )r	   r   )Úfilenamer'   Úprogress_filterÚdriversÚdrivers        r   r
   r
   W   sv   € ð. Ð/Õ/ð ð ˆð	ØˆF�8˜[¨/Ñ:Ô:Ð:ð ˆFˆFøõ "ð 	ð 	ð 	ØˆHð	øøøõ ÐI¸xÐIÐIÑ
JÔ
JÐJs   ��
*©*c                 ó|  — t           j                             | ¦  «        st          | › d�¦  «        ‚| d|fi}t          j        | ¦  «        D ]ï\  }}}||         \  }}|D ]K}	||	z   dz   t           j                             ||	¦  «        f|t           j                             ||	¦  «        <   ŒL|D ]�}
t           j                             ||
¦  «        } |||
z   |¦  «        }|sŒ4t          |¦  «         t           j                             ||
¦  «        }
t          j        |
|¦  «         t          j	        |
|¦  «         ŒŽŒðdS )zˆ "Unpack" a directory, using the same interface as for archives

    Raises ``UnrecognizedFormat`` if `filename` is not a directory
    z is not a directoryr   r   N)
r#   r$   Úisdirr   Úwalkr%   r   ÚshutilÚcopyfileÚcopystat)r0   r'   r1   ÚpathsÚbaseÚdirsÚfilesr   r   ÚdÚfÚtargets               r   r   r   x   s\  € õ
 Œ7�=Š=˜Ñ"Ô"ð CÝ  HÐ!AÐ!AÐ!AÑBÔBÐBð 	�2�{Ð#ð€Eõ  œW XÑ.Ô.ð 'ð 'Ñˆˆd�EØ˜”;‰ˆˆSØð 	Oð 	OˆAØ+.°©7°S©=½"¼'¿,º,ÀsÈAÑ:NÔ:NÐ+NˆE•"”'—,’,˜t QÑ'Ô'Ñ(Ð(Øð 		'ð 		'ˆAÝ”W—\’\ # qÑ)Ô)ˆFØ$�_ S¨1¡W¨fÑ5Ô5ˆFØð àÝ˜VÑ$Ô$Ð$Ý”—’˜T 1Ñ%Ô%ˆAÝŒO˜A˜vÑ&Ô&Ð&ÝŒO˜A˜vÑ&Ô&Ð&Ð&ð		'ð	'ð 'r   c                 óÎ   — t          j        | ¦  «        st          | › d�¦  «        ‚t          j        | ¦  «        5 }t	          |||¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zòUnpack zip `filename` to `extract_dir`

    Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined
    by ``zipfile.is_zipfile()``).  See ``unpack_archive()`` for an explanation
    of the `progress_filter` argument.
    z is not a zip fileN)ÚzipfileÚ
is_zipfiler   ÚZipFileÚ_unpack_zipfile_obj)r0   r'   r1   Úzs       r   r   r   “   s²   € õ Ô˜hÑ'Ô'ð BÝ  HÐ!@Ð!@Ð!@ÑAÔAÐAå	Œ˜Ñ	"Ô	"ð = aÝ˜A˜{¨OÑ<Ô<Ð<ð=ð =ð =ñ =ô =ð =ð =ð =ð =ð =ð =ð =øøøð =ð =ð =ð =ð =ð =s   »AÁAÁ!Ac                 óØ  — |                       ¦   «         D ]Ô}|j        }t          ||¦  «        } |||¦  «        }|sŒ(|                     d¦  «        rt	          |¦  «         nft	          |¦  «         |                      |j        ¦  «        }t          |d¦  «        5 }|                     |¦  «         ddd¦  «         n# 1 swxY w Y   |j        dz	  }|rt          j
        ||¦  «         ŒÕdS )z·Internal/private API used by other parts of setuptools.
    Similar to ``unpack_zipfile``, but receives an already opened :obj:`zipfile.ZipFile`
    object instead of a filename.
    r   ÚwbNé   )Úinfolistr0   r-   Úendswithr   ÚreadÚopenÚwriteÚexternal_attrr#   Úchmod)	Úzipfile_objr'   r1   Úinfor(   r@   Údatar?   Úunix_attributess	            r   rE   rE   ¢   s>  € ð
 ×$Ò$Ñ&Ô&ð .ð .ˆØŒ}ˆå˜{¨DÑ1Ô1ˆØ �  vÑ.Ô.ˆØð 	ØØ�=Š=˜ÑÔð 	å˜VÑ$Ô$Ð$Ð$õ ˜VÑ$Ô$Ð$Ø×#Ò# D¤MÑ2Ô2ˆDÝ�f˜dÑ#Ô#ð  qØ—’˜‘”�ðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð àÔ,°Ñ2ˆØð 	.ÝŒH�V˜_Ñ-Ô-Ð-øð%.ð .s   ÂB=Â=C	ÃC	c                 ó  — |�Ä|                      ¦   «         s|                     ¦   «         rœ|j        }|                     ¦   «         rBt          j        |j        ¦  «        }t          j        ||¦  «        }t          j        |¦  «        }|                      |¦  «        }|�(|                      ¦   «         °ˆ|                     ¦   «         °œ|duo'| 	                    ¦   «         p| 
                    ¦   «         }|r|S t          d¦  «        ‚)z;Resolve any links and extract link targets as normal files.NzGot unknown file type)ÚislnkÚissymÚlinknameÚ	posixpathÚdirnamer(   r%   ÚnormpathÚ
_getmemberÚisfiler5   ÚLookupError)Útar_objÚtar_member_objÚlinkpathr;   Úis_file_or_dirs        r   Ú_resolve_tar_file_or_dirrc   ¼   s  € à
Ð
$Ø×ÒÑÔð %Ø"0×"6Ò"6Ñ"8Ô"8ð %ð "Ô*ˆØ×ÒÑ!Ô!ð 	4ÝÔ$ ^Ô%8Ñ9Ô9ˆDÝ ”~ d¨HÑ5Ô5ˆHÝ Ô)¨(Ñ3Ô3ˆHØ ×+Ò+¨HÑ5Ô5ˆð Ð
$Ø×ÒÑÔð %Ø"0×"6Ò"6Ñ"8Ô"8ð %ð $¨4Ð/ð Ø×ÒÑÔÐ9 >×#7Ò#7Ñ#9Ô#9ð ð ð ØÐå
Ð-Ñ
.Ô
.Ð.r   c              #   ón  K  — d„ | _         t          j        | ¦  «        5  | D ]y}|j        }t	          ||¦  «        }	 t          | |¦  «        }n# t          $ r Y Œ7w xY w |||¦  «        }|sŒJ|                     t          j	        ¦  «        r
|dd…         }||fV — Œz	 ddd¦  «         dS # 1 swxY w Y   dS )z1Emit member-destination pairs from a tar archive.c                  ó   — d S )Nr   )Úargss    r   ú<lambda>z _iter_open_tar.<locals>.<lambda>Ô   s   €  $€ r   Néÿÿÿÿ)
ÚchownÚ
contextlibÚclosingr(   r-   rc   r^   rK   r#   Úsep)r_   r'   r1   Úmemberr(   Ú
prelim_dstÚ	final_dsts          r   Ú_iter_open_tarrp   Ñ   s>  è è € ð 'Ð&€G„Må	Ô	˜GÑ	$Ô	$ð $ð $Øð 	$ð 	$ˆFØ”;ˆDÝ& {°DÑ9Ô9ˆJðÝ1°'¸6ÑBÔB��øÝð ð ð Ø�ðøøøð (˜¨¨jÑ9Ô9ˆIØð Øà×!Ò!¥"¤&Ñ)Ô)ð +Ø% c r cœN�	à˜)Ð#Ð#Ð#Ð#Ð#ð!	$ð$ð $ð $ñ $ô $ð $ð $ð $ð $ð $ð $ð $øøøð $ð $ð $ð $ð $ð $s5   ŸB*¼AÁB*Á
AÁB*ÁAÁAB*Â*B.Â1B.c                 ó  — 	 t          j        | ¦  «        }n*# t           j        $ r}t          | › d�¦  «        |‚d}~ww xY wt	          |||¦  «        D ]1\  }}	 |                     ||¦  «         Œ# t           j        $ r Y Œ.w xY wdS )zûUnpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`

    Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined
    by ``tarfile.open()``).  See ``unpack_archive()`` for an explanation
    of the `progress_filter` argument.
    z- is not a compressed or uncompressed tar fileNT)ÚtarfilerM   ÚTarErrorr   rp   Ú_extract_memberÚExtractError)r0   r'   r1   ÚtarobjÚerm   ro   s          r   r   r   ê   sÌ   € ðÝ”˜hÑ'Ô'ˆˆøÝÔð ð ð Ý ØÐFÐFÐFñ
ô 
àð	øøøøðøøøõ
 ,ØØØñô ð 
ð 
Ñˆ�	ð
	à×"Ò" 6¨9Ñ5Ô5Ð5Ð5øÝÔ#ð 	ð 	ð 	àˆDð	øøøð ˆ4s"   ‚ —>¦9¹>ÁA/Á/BÂ B)r.   N)r   rj   r    r#   rY   r7   rr   rB   Ú_pathr   Údistutils.errorsr   Ú__all__r   r   r   r-   r
   r   r   rE   rc   rp   Úboolr   r	   r   r   r   ú<module>r|      sÓ  ðØ 5Ð 5à Ð Ð Ð Ø €€€Ø 	€	€	€	Ø Ð Ð Ð Ø €€€Ø €€€Ø €€€à #Ð #Ð #Ð #Ð #Ð #à +Ð +Ð +Ð +Ð +Ð +ð	ð 	ð 	€ð.ð .ð .ð .ð .˜ñ .ô .ð .ðð ð ð ð �>ñ ô ð ðð ð ð
'ð 'ð 'ðV ,:À4ðKà	ðKð Kð Kð KðB =Kð 'ð 'ð 'ð 'ð 'ð6 ;Ið =ð =ð =ð =ð =ð CQð .ð .ð .ð .ð4/ð /ð /ð*$ð $ð $ð2 ;Ið ð ÈTð ð ð ð ð: & ~°~ÐEÐ Ð Ð r   