Ë
    óÿæi/  ã                   ó  — 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Zddl	Z	ddl
mZmZ ddlmZ ddlmZ dgZd„ Zd	„ Zej*                  Z	 d
„ Z G d„ d«      Z G d„ dee	j2                  «      Z G d„ de«      Zdd„Z G d„ d«      Zy)zÒ
A Path-like interface for zipfiles.

This codebase is shared between zipfile.Path in the stdlib
and zipp in PyPI. See
https://github.com/python/importlib_metadata/wiki/Development-Methodology
for more detail.
é    Né   )Únone_asÚsave_method_args)Útext_encoding)Ú
TranslatorÚPathc                 óB   — t        j                  t        | «      dd«      S )a2  
    Given a path with elements separated by
    posixpath.sep, generate all parents of that path.

    >>> list(_parents('b/d'))
    ['b']
    >>> list(_parents('/b/d/'))
    ['/b']
    >>> list(_parents('b/d/f/'))
    ['b/d', 'b']
    >>> list(_parents('b'))
    []
    >>> list(_parents(''))
    []
    r   N)Ú	itertoolsÚisliceÚ	_ancestry)Úpaths    úb/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/zipp/__init__.pyÚ_parentsr      s   € ô  ×ÑœI d›O¨Q°Ó5Ð5ó    c              #   ó  K  — | j                  t        j                  «      } | j                  t        j                  «      r=| –— t        j                  | «      \  } }| j                  t        j                  «      rŒ<yy­w)aÔ  
    Given a path with elements separated by
    posixpath.sep, generate all elements of that path.

    >>> list(_ancestry('b/d'))
    ['b/d', 'b']
    >>> list(_ancestry('/b/d/'))
    ['/b/d', '/b']
    >>> list(_ancestry('b/d/f/'))
    ['b/d/f', 'b/d', 'b']
    >>> list(_ancestry('b'))
    ['b']
    >>> list(_ancestry(''))
    []

    Multiple separators are treated like a single.

    >>> list(_ancestry('//b//d///f//'))
    ['//b//d///f', '//b//d', '//b']
    N)ÚrstripÚ	posixpathÚsepÚsplit)r   Útails     r   r   r   .   sS   è ø€ ð* �;‰;”y—}‘}Ó%€DØ
�+‰+”i—m‘mÔ
$ØŠ
Ü—_‘_ TÓ*‰
ˆˆdð �+‰+”i—m‘m×
$ùs   ‚A:A?Á=A?c                 óT   — t        j                  t        |«      j                  | «      S )zZ
    Return items in minuend not in subtrahend, retaining order
    with O(1) lookup.
    )r
   ÚfilterfalseÚsetÚ__contains__)ÚminuendÚ
subtrahends     r   Ú_differencer   M   s!   € ô
 × Ñ ¤ Z£×!=Ñ!=¸wÓGÐGr   c                   ó<   ‡ — e Zd ZdZeˆ fd„«       Zd„ Zˆ fd„Zˆ xZS )ÚInitializedStatez?
    Mix-in to save the initialization state for pickling.
    c                 ó$   •— t        ‰| �  |i |¤Ž y ©N©ÚsuperÚ__init__)ÚselfÚargsÚkwargsÚ	__class__s      €r   r$   zInitializedState.__init__Z   s   ø€ ä‰Ñ˜$Ð) &Ó)r   c                 óZ   — | j                   j                  | j                   j                  fS r!   )Ú_saved___init__r&   r'   ©r%   s    r   Ú__getstate__zInitializedState.__getstate__^   s%   € Ø×#Ñ#×(Ñ(¨$×*>Ñ*>×*EÑ*EÐEÐEr   c                 ó.   •— |\  }}t        ‰| �  |i |¤Ž y r!   r"   )r%   Ústater&   r'   r(   s       €r   Ú__setstate__zInitializedState.__setstate__a   s   ø€ Ø‰ˆˆfÜ‰Ñ˜$Ð) &Ó)r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r$   r,   r/   Ú__classcell__©r(   s   @r   r   r   U   s,   ø„ ñð ó*ó ð*òF÷*ð *r   r   c                   óš   ‡ — e Zd ZdZed„ «       Zˆ fd„Zd„ Zd„ Zˆ fd„Z	e
d„ «       Ze
dej                  d	ej                  fd
„«       Zˆ xZS )ÚCompleteDirsa8  
    A ZipFile subclass that ensures that implied directories
    are always included in the namelist.

    >>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt']))
    ['foo/', 'foo/bar/']
    >>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt', 'foo/bar/']))
    ['foo/']
    c                 ó˜   — t         j                  j                  t        t        | «      «      }d„ |D «       }t        t        || «      «      S )Nc              3   óB   K  — | ]  }|t         j                  z   –— Œ y ­wr!   )r   r   )Ú.0Úps     r   Ú	<genexpr>z-CompleteDirs._implied_dirs.<locals>.<genexpr>t   s   è ø€ Ð6©g¨�1”y—}‘}Õ$©gùs   ‚)r
   ÚchainÚfrom_iterableÚmapr   Ú_deduper   )ÚnamesÚparentsÚas_dirss      r   Ú_implied_dirszCompleteDirs._implied_dirsq   s9   € ä—/‘/×/Ñ/´´H¸eÓ0DÓEˆÙ6©gÓ6ˆÜ”{ 7¨EÓ2Ó3Ð3r   c                 óZ   •— t         ‰| �  «       }|t        | j                  |«      «      z   S r!   )r#   ÚnamelistÚlistrD   )r%   rA   r(   s     €r   rF   zCompleteDirs.namelistw   s+   ø€ Ü‘Ñ Ó"ˆØ”t˜D×.Ñ.¨uÓ5Ó6Ñ6Ð6r   c                 ó4   — t        | j                  «       «      S r!   )r   rF   r+   s    r   Ú	_name_setzCompleteDirs._name_set{   s   € Ü�4—=‘=“?Ó#Ð#r   c                 óL   — | j                  «       }|dz   }||vxr ||v }|r|S |S )zx
        If the name represents a directory, return that name
        as a directory (with the trailing slash).
        Ú/)rI   )r%   ÚnamerA   ÚdirnameÚ	dir_matchs        r   Úresolve_dirzCompleteDirs.resolve_dir~   s:   € ð
 —‘Ó ˆØ˜‘*ˆØ Ð%Ò:¨'°UÐ*:ˆ	Ù#ˆwÐ-¨Ð-r   c                 ó¶   •— 	 t         ‰| �  |«      S # t        $ r= |j                  d«      r|| j	                  «       vr‚ t        j                  |¬«      cY S w xY w)z6
        Supplement getinfo for implied dirs.
        rK   )Úfilename)r#   ÚgetinfoÚKeyErrorÚendswithrI   ÚzipfileÚZipInfo)r%   rL   r(   s     €r   rR   zCompleteDirs.getinfoˆ   sR   ø€ ð	2Ü‘7‘? 4Ó(Ð(øÜò 	2Ø—=‘= Ô%¨°T·^±^Ó5EÑ)EØÜ—?‘?¨DÔ1Ò1ð	2ús   ƒ ’AAÁAc                 ó¤   — t        |t        «      r|S t        |t        j                  «      s | |«      S d|j                  vrt        } | |_        |S )zl
        Given a source (filename or zipfile), return an
        appropriate CompleteDirs subclass.
        Úr)Ú
isinstancer7   rU   ÚZipFileÚmoder(   )ÚclsÚsources     r   ÚmakezCompleteDirs.make“   sK   € ô �fœlÔ+ØˆMä˜&¤'§/¡/Ô2Ù�v“;Ðð �f—k‘kÑ!ÜˆCàˆÔØˆr   ÚzfÚreturnc                 ór   — | j                  |j                  «       «      D ]  }|j                  |d«       Œ |S )z‰
        Given a writable zip file zf, inject directory entries for
        any directories implied by the presence of children.
        r   )rD   rF   Úwritestr)r\   r_   rL   s      r   ÚinjectzCompleteDirs.inject¦   s2   € ð ×%Ñ% b§k¡k£mÖ4ˆDØ�K‰K˜˜cÕ"ð 5àˆ	r   )r0   r1   r2   r3   ÚstaticmethodrD   rF   rI   rO   rR   Úclassmethodr^   rU   rZ   rc   r4   r5   s   @r   r7   r7   f   sn   ø„ ñð ñ4ó ð4ô
7ò$ò.ô	2ð ñó ðð$ ð˜Ÿ™ð ¨G¯O©Oò ó ôr   r7   c                   ót   ‡ — e Zd ZdZd„ Zej                  ˆ fd„«       Zd„ Zej                  ˆ fd„«       Z	ˆ xZ
S )Ú
FastLookupzV
    ZipFile subclass to ensure implicit
    dirs exist and are resolved rapidly.
    c                 ó   — | j                   S r!   )Ú	_namelistr+   s    r   rF   zFastLookup.namelist·   s   € Ø�~‰~Ðr   c                 ó    •— t         ‰| �  «       S r!   )r#   rF   ©r%   r(   s    €r   ri   zFastLookup._namelistº   s   ø€ ä‰wÑÓ!Ð!r   c                 ó   — | j                   S r!   )Ú_name_set_propr+   s    r   rI   zFastLookup._name_set¾   s   € Ø×"Ñ"Ð"r   c                 ó    •— t         ‰| �  «       S r!   )r#   rI   rk   s    €r   rm   zFastLookup._name_set_propÁ   s   ø€ ä‰wÑ Ó"Ð"r   )r0   r1   r2   r3   rF   Ú	functoolsÚcached_propertyri   rI   rm   r4   r5   s   @r   rg   rg   ±   sF   ø„ ñò
ð ×Ñó"ó ð"ò#ð ×Ñó#ó ô#r   rg   c                 ó’   — t         j                  j                  dk(  }|xr t         j                  dk  }d|z   }t	        | |«      ||fS )NÚpypy)é   é   é   rt   )ÚsysÚimplementationrL   Úpypy_version_infor   )Úencodingr&   r'   Úis_pypyÚis_old_pypiÚstack_levels         r   Ú_extract_text_encodingr}   Æ   sL   € ä× Ñ ×%Ñ%¨Ñ/€Gð Ò@œc×3Ñ3°jÑ@€KØ�k‘/€KÜ˜ ;Ó/°°vÐ=Ð=r   c                   ó   — e Zd ZdZdZd d„Zd„ Zd„ Zd!ddœd„Zd	„ Z	e
d
„ «       Ze
d„ «       Ze
d„ «       Ze
d„ «       Ze
d„ «       Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZeZ e
d„ «       Z!y)"r   u#  
    A :class:`importlib.resources.abc.Traversable` interface for zip files.

    Implements many of the features users enjoy from
    :class:`pathlib.Path`.

    Consider a zip file with this structure::

        .
        â”œâ”€â”€ a.txt
        â””â”€â”€ b
            â”œâ”€â”€ c.txt
            â””â”€â”€ d
                â””â”€â”€ e.txt

    >>> data = io.BytesIO()
    >>> zf = zipfile.ZipFile(data, 'w')
    >>> zf.writestr('a.txt', 'content of a')
    >>> zf.writestr('b/c.txt', 'content of c')
    >>> zf.writestr('b/d/e.txt', 'content of e')
    >>> zf.filename = 'mem/abcde.zip'

    Path accepts the zipfile object itself or a filename

    >>> path = Path(zf)

    From there, several path operations are available.

    Directory iteration (including the zip file itself):

    >>> a, b = path.iterdir()
    >>> a
    Path('mem/abcde.zip', 'a.txt')
    >>> b
    Path('mem/abcde.zip', 'b/')

    name property:

    >>> b.name
    'b'

    join with divide operator:

    >>> c = b / 'c.txt'
    >>> c
    Path('mem/abcde.zip', 'b/c.txt')
    >>> c.name
    'c.txt'

    Read text:

    >>> c.read_text(encoding='utf-8')
    'content of c'

    existence:

    >>> c.exists()
    True
    >>> (b / 'missing.txt').exists()
    False

    Coercion to string:

    >>> import os
    >>> str(c).replace(os.sep, posixpath.sep)
    'mem/abcde.zip/b/c.txt'

    At the root, ``name``, ``filename``, and ``parent``
    resolve to the zipfile.

    >>> str(path)
    'mem/abcde.zip'
    >>> path.name
    'abcde.zip'
    >>> path.filename == pathlib.Path('mem/abcde.zip')
    True
    >>> str(path.parent)
    'mem'

    If the zipfile has no filename, such attributes are not
    valid and accessing them will raise an Exception.

    >>> zf.filename = None
    >>> path.name
    Traceback (most recent call last):
    ...
    TypeError: ...

    >>> path.filename
    Traceback (most recent call last):
    ...
    TypeError: ...

    >>> path.parent
    Traceback (most recent call last):
    ...
    TypeError: ...

    # workaround python/cpython#106763
    >>> pass
    z>{self.__class__.__name__}({self.root.filename!r}, {self.at!r})c                 óF   — t         j                  |«      | _        || _        y)aX  
        Construct a Path from a ZipFile or filename.

        Note: When the source is an existing ZipFile object,
        its type (__class__) will be mutated to a
        specialized type. If the caller wishes to retain the
        original type, the caller should either create a
        separate ZipFile object or pass a filename.
        N)rg   r^   ÚrootÚat)r%   r€   r�   s      r   r$   zPath.__init__9  s   € ô —O‘O DÓ)ˆŒ	Øˆ�r   c                 ó    — | j                   |j                   urt        S | j                  | j                  f|j                  |j                  fk(  S )zU
        >>> Path(zipfile.ZipFile(io.BytesIO(), 'w')) == 'foo'
        False
        )r(   ÚNotImplementedr€   r�   )r%   Úothers     r   Ú__eq__zPath.__eq__F  s?   € ð
 �>‰> §¡Ñ0Ü!Ð!Ø—	‘	˜4Ÿ7™7Ð#¨¯
©
°E·H±HÐ'=Ñ=Ð=r   c                 óD   — t        | j                  | j                  f«      S r!   )Úhashr€   r�   r+   s    r   Ú__hash__zPath.__hash__O  s   € Ü�T—Y‘Y §¡Ð(Ó)Ð)r   N©Úpwdc                óN  — | j                  «       rt        | «      ‚|d   }|dk(  r| j                  «       st        | «      ‚| j                  j                  | j                  ||¬«      }d|v r|s|rt        d«      ‚|S t        |i |¤Ž\  }}}t        j                  ||g|¢­i |¤ŽS )zª
        Open this entry as text or binary following the semantics
        of ``pathlib.Path.open()`` by passing arguments through
        to io.TextIOWrapper().
        r   rX   r‰   Úbz*encoding args invalid for binary operation)Úis_dirÚIsADirectoryErrorÚexistsÚFileNotFoundErrorr€   Úopenr�   Ú
ValueErrorr}   ÚioÚTextIOWrapper)r%   r[   rŠ   r&   r'   Úzip_modeÚstreamry   s           r   r‘   z	Path.openR  s§   € ð �;‰;Œ=Ü# DÓ)Ð)Ø˜‘7ˆØ�sŠ? 4§;¡;¤=Ü# DÓ)Ð)Ø—‘—‘ §¡¨°s�Ó;ˆØ�$‰;Ù‘vÜ Ð!MÓNÐNØˆMä!7¸Ð!HÀÑ!HÑˆ�$˜Ü×Ñ ¨ÐB°4ÒB¸6ÑBÐBr   c                 óp   — | j                   rt        j                  | j                   «      S | j                  S r!   )r�   ÚpathlibÚPurePosixPathrQ   r+   s    r   Ú_basez
Path._basef  s&   € Ø15·²Œw×$Ñ$ T§W¡WÓ-ÐK¸d¿m¹mÐKr   c                 ó6   — | j                  «       j                  S r!   )rš   rL   r+   s    r   rL   z	Path.namei  ó   € à�z‰z‹|× Ñ Ð r   c                 ó6   — | j                  «       j                  S r!   )rš   Úsuffixr+   s    r   rž   zPath.suffixm  s   € à�z‰z‹|×"Ñ"Ð"r   c                 ó6   — | j                  «       j                  S r!   )rš   Úsuffixesr+   s    r   r    zPath.suffixesq  s   € à�z‰z‹|×$Ñ$Ð$r   c                 ó6   — | j                  «       j                  S r!   )rš   Ústemr+   s    r   r¢   z	Path.stemu  rœ   r   c                 ó†   — t        j                  | j                  j                  «      j	                  | j
                  «      S r!   )r˜   r   r€   rQ   Újoinpathr�   r+   s    r   rQ   zPath.filenamey  s*   € ä�|‰|˜DŸI™I×.Ñ.Ó/×8Ñ8¸¿¹ÓAÐAr   c                 óš   — t        |i |¤Ž\  }}} | j                  d|g|¢­i |¤Ž5 }|j                  «       cd d d «       S # 1 sw Y   y xY w)NrX   )r}   r‘   Úread)r%   r&   r'   ry   Ústrms        r   Ú	read_textzPath.read_text}  sI   € Ü!7¸Ð!HÀÑ!HÑˆ�$˜ØˆT�Y‰Y�s˜HÐ6 tÒ6¨vÒ6¸$Ø—9‘9“;÷ 7×6Ò6ús   §AÁA
c                 óp   — | j                  d«      5 }|j                  «       cd d d «       S # 1 sw Y   y xY w)NÚrb)r‘   r¦   )r%   r§   s     r   Ú
read_byteszPath.read_bytes‚  s"   € Ø�Y‰Y�tŒ_ Ø—9‘9“;÷ �_Š_ús   ’,¬5c                 ó–   — t        j                  |j                  j                  d«      «      | j                  j                  d«      k(  S ©NrK   )r   rM   r�   r   )r%   r   s     r   Ú	_is_childzPath._is_child†  s2   € Ü× Ñ  §¡§¡°Ó!4Ó5¸¿¹¿¹ÈÓ9LÑLÐLr   c                 ó:   — | j                  | j                  |«      S r!   )r(   r€   )r%   r�   s     r   Ú_nextz
Path._next‰  s   € Ø�~‰~˜dŸi™i¨Ó,Ð,r   c                 óV   — | j                    xs | j                   j                  d«      S r­   )r�   rT   r+   s    r   r�   zPath.is_dirŒ  s"   € Ø—7‘7ˆ{Ò3˜dŸg™g×.Ñ.¨sÓ3Ð3r   c                 óH   — | j                  «       xr | j                  «        S r!   )r�   r�   r+   s    r   Úis_filezPath.is_file�  s   € Ø�{‰{‹}Ò2 T§[¡[£]Ð!2Ð2r   c                 óN   — | j                   | j                  j                  «       v S r!   )r�   r€   rI   r+   s    r   r�   zPath.exists’  s   € Ø�w‰w˜$Ÿ)™)×-Ñ-Ó/Ð/Ð/r   c                 óÀ   — | j                  «       st        d«      ‚t        | j                  | j                  j                  «       «      }t        | j                  |«      S )NzCan't listdir a file)r�   r’   r?   r°   r€   rF   Úfilterr®   )r%   Úsubss     r   ÚiterdirzPath.iterdir•  sE   € Ø�{‰{Œ}ÜÐ3Ó4Ð4Ü�4—:‘:˜tŸy™y×1Ñ1Ó3Ó4ˆÜ�d—n‘n dÓ+Ð+r   c                 ó^   — t        j                  | j                  «      j                  |«      S r!   )r˜   r™   r�   Úmatch)r%   Úpath_patterns     r   rº   z
Path.match›  s"   € Ü×$Ñ$ T§W¡WÓ-×3Ñ3°LÓAÐAr   c                 ó”   — | j                   j                  | j                  «      }|j                  dz	  }t	        j
                  |«      S )z8
        Return whether this path is a symlink.
        é   )r€   rR   r�   Úexternal_attrÚstatÚS_ISLNK)r%   Úinfor[   s      r   Ú
is_symlinkzPath.is_symlinkž  s;   € ð �y‰y× Ñ  §¡Ó)ˆØ×!Ñ! RÑ'ˆÜ�|‰|˜DÓ!Ð!r   c                 óJ  — |st        d|›�«      ‚t        j                  | j                  «      }t	        d¬«      }t        j
                  ||j                  |«      z   «      j                  }t        | j                  t        || j                  j                  «       «      «      S )NzUnacceptable pattern: rK   )Úseps)r’   ÚreÚescaper�   r   ÚcompileÚ	translateÚ	fullmatchr?   r°   r¶   r€   rF   )r%   ÚpatternÚprefixÚtrÚmatchess        r   Úglobz	Path.glob¦  s{   € ÙÜÐ5°g°[ÐAÓBÐBä—‘˜4Ÿ7™7Ó#ˆÜ˜SÔ!ˆÜ—*‘*˜V b§l¡l°7Ó&;Ñ;Ó<×FÑFˆÜ�4—:‘:œv g¨t¯y©y×/AÑ/AÓ/CÓDÓEÐEr   c                 ó*   — | j                  d|› �«      S )Nz**/)rÎ   )r%   rÊ   s     r   Úrglobz
Path.rglob¯  s   € Ø�y‰y˜3˜w˜i˜Ó)Ð)r   c                 ól   — t        j                  t        | «      t         |j                  |Ž «      «      S r!   )r   ÚrelpathÚstrr¤   )r%   r„   Úextras      r   Úrelative_tozPath.relative_to²  s)   € Ü× Ñ ¤ T£¬C°°·±ÀÐ0FÓ,GÓHÐHr   c                 óž   — t        | j                  j                  d«      }| j                  r t	        j
                  || j                  «      S |S )Nz	:zipfile:)r   r€   rQ   r�   r   Újoin)r%   r€   s     r   Ú__str__zPath.__str__µ  s8   € Ü�t—y‘y×)Ñ)¨;Ó7ˆØ04·²Œy�~‰~˜d D§G¡GÓ,ÐA¸TÐAr   c                 ó:   — | j                   j                  | ¬«      S )Nr+   )Ú_Path__reprÚformatr+   s    r   Ú__repr__zPath.__repr__¹  s   € Ø�{‰{×!Ñ! tÐ!Ó,Ð,r   c                 ó–   — t        j                  | j                  g|¢­Ž }| j                  | j                  j                  |«      «      S r!   )r   r×   r�   r°   r€   rO   )r%   r„   Únexts      r   r¤   zPath.joinpath¼  s7   € Ü�~‰~˜dŸg™gÐ.¨Ò.ˆØ�z‰z˜$Ÿ)™)×/Ñ/°Ó5Ó6Ð6r   c                 óÒ   — | j                   s| j                  j                  S t        j                  | j                   j                  d«      «      }|r|dz  }| j                  |«      S r­   )r�   rQ   Úparentr   rM   r   r°   )r%   Ú	parent_ats     r   rà   zPath.parentÂ  sR   € à�wŠwØ—=‘=×'Ñ'Ð'Ü×%Ñ% d§g¡g§n¡n°SÓ&9Ó:ˆ	ÙØ˜ÑˆIØ�z‰z˜)Ó$Ð$r   )Ú )rX   )"r0   r1   r2   r3   rÚ   r$   r…   rˆ   r‘   rš   ÚpropertyrL   rž   r    r¢   rQ   r¨   r«   r®   r°   r�   r³   r�   r¸   rº   rÂ   rÎ   rÐ   rÕ   rØ   rÜ   r¤   Ú__truediv__rà   © r   r   r   r   Ð   s  „ ñdðL N€Fóò>ò*ðC¨ô Cò(Lð ñ!ó ð!ð ñ#ó ð#ð ñ%ó ð%ð ñ!ó ð!ð ñBó ðBòò
òMò-ò4ò3ò0ò,òBò"òFò*òIòBò-ò7ð €Kàñ%ó ñ%r   r!   )r3   ro   r“   r
   r˜   r   rÅ   r¿   rv   rU   Ú
_functoolsr   r   Úcompat.py310r   rÎ   r   Ú__all__r   r   ÚdictÚfromkeysr@   r   r   rZ   r7   rg   r}   r   rå   r   r   Ú<module>rë      s’   ðñó Û 	Û Û Û Û 	Û Û 
Û ç 1Ý 'Ý àˆ(€ò6ò&+ð6 �-‰-€Ø /òH÷*ñ *ô"HÐ# W§_¡_ô HôV#�ô #ó*>÷y%ò y%r   