Ë
    gKê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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j0                  «      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    úR/home/oem/CyberBrain26-unified/.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Ô
$ØŠ
Ü—o‘o dÓ+‰ˆˆeð �+‰+”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   L   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__Y   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__`   s   ø€ Ø‰ˆˆfÜ‰Ñ˜$Ð) &Ó)r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r%   r-   r0   Ú__classcell__©r)   s   @r   r    r    T   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>s   s   è ø€ Ò6¨�1”y—}‘}Õ$Ñ6ùs   ‚)r   ÚchainÚfrom_iterableÚmapr   Ú_deduper   )ÚnamesÚparentsÚas_dirss      r   Ú_implied_dirszCompleteDirs._implied_dirsp   s9   € ä—/‘/×/Ñ/´´H¸eÓ0DÓEˆÙ6¨gÔ6ˆÜ”{ 7¨EÓ2Ó3Ð3r   c                 óZ   •— t         ‰| �  «       }|t        | j                  |«      «      z   S r"   )r$   ÚnamelistÚlistrE   )r&   rB   r)   s     €r   rG   zCompleteDirs.namelistv   s+   ø€ Ü‘Ñ Ó"ˆØ”t˜D×.Ñ.¨uÓ5Ó6Ñ6Ð6r   c                 ó4   — t        | j                  «       «      S r"   )r   rG   r,   s    r   Ú	_name_setzCompleteDirs._name_setz   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).
        ú/)rJ   )r&   ÚnamerB   Ú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.
        rL   )Úfilename)r$   ÚgetinfoÚKeyErrorÚendswithrJ   ÚzipfileÚZipInfo)r&   rM   r)   s     €r   rS   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	| |_        |S t        |_        |S )zl
        Given a source (filename or zipfile), return an
        appropriate CompleteDirs subclass.
        Úr)Ú
isinstancer8   rV   ÚZipFileÚmoder)   )ÚclsÚsources     r   ÚmakezCompleteDirs.make’   sU   € ô �fœlÔ+ØˆMä˜&¤'§/¡/Ô2Ù�v“;Ðð #&¨¯©Ñ"4˜3ˆÔØˆô ;GˆÔØˆ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   )rE   rG   Úwritestr)r]   r`   rM   s      r   ÚinjectzCompleteDirs.inject¢   s7   € ð ×%Ñ% b§k¡k£mÓ4ò 	#ˆDØ�K‰K˜˜cÕ"ð	#àˆ	r   )r1   r2   r3   r4   ÚstaticmethodrE   rG   rJ   rP   rS   Úclassmethodr_   rV   r[   rd   r5   r6   s   @r   r8   r8   e   sn   ø„ ñð ñ4ó ð4ô
7ò$ò.ô	2ð ñó ðð ð˜Ÿ™ð ¨G¯O©Oò ó ôr   r8   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   rG   zFastLookup.namelist³   s   € Ø�~‰~Ðr   c                 ó    •— t         ‰| �  «       S r"   )r$   rG   ©r&   r)   s    €r   rj   zFastLookup._namelist¶   s   ø€ ä‰wÑÓ!Ð!r   c                 ó   — | j                   S r"   )Ú_name_set_propr,   s    r   rJ   zFastLookup._name_setº   s   € Ø×"Ñ"Ð"r   c                 ó    •— t         ‰| �  «       S r"   )r$   rJ   rl   s    €r   rn   zFastLookup._name_set_prop½   s   ø€ ä‰wÑ Ó"Ð"r   )r1   r2   r3   r4   rG   Ú	functoolsÚcached_propertyrj   rJ   rn   r5   r6   s   @r   rh   rh   ­   sF   ø„ ñò
ð ×Ñó"ó ð"ò#ð ×Ñó#ó ô#r   rh   c                 ó$   — d}t        | |«      ||fS )Né   r   )Úencodingr'   r(   Ústack_levels       r   Ú_extract_text_encodingrv   Â   s   € Ø€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)rh   r_   ÚrootÚat)r&   ry   rz   s      r   r%   zPath.__init__0  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)   ÚNotImplementedry   rz   )r&   Úothers     r   Ú__eq__zPath.__eq__=  s?   € ð
 �>‰> §¡Ñ0Ü!Ð!Ø—	‘	˜4Ÿ7™7Ð#¨¯
©
°E·H±HÐ'=Ñ=Ð=r   c                 óD   — t        | j                  | j                  f«      S r"   )Úhashry   rz   r,   s    r   Ú__hash__zPath.__hash__F  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   rY   r‚   Úbz*encoding args invalid for binary operation)Úis_dirÚIsADirectoryErrorÚexistsÚFileNotFoundErrorry   Úopenrz   Ú
ValueErrorrv   ÚioÚTextIOWrapper)r&   r\   rƒ   r'   r(   Úzip_modeÚstreamrt   s           r   rŠ   z	Path.openI  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"   )rz   ÚpathlibÚPurePosixPathrR   r,   s    r   Ú_basez
Path._base]  s&   € Ø15·²Œw×$Ñ$ T§W¡WÓ-ÐK¸d¿m¹mÐKr   c                 ó6   — | j                  «       j                  S r"   )r“   rM   r,   s    r   rM   z	Path.name`  ó   € à�z‰z‹|× Ñ Ð r   c                 ó6   — | j                  «       j                  S r"   )r“   Úsuffixr,   s    r   r—   zPath.suffixd  s   € à�z‰z‹|×"Ñ"Ð"r   c                 ó6   — | j                  «       j                  S r"   )r“   Úsuffixesr,   s    r   r™   zPath.suffixesh  s   € à�z‰z‹|×$Ñ$Ð$r   c                 ó6   — | j                  «       j                  S r"   )r“   Ústemr,   s    r   r›   z	Path.steml  r•   r   c                 ó†   — t        j                  | j                  j                  «      j	                  | j
                  «      S r"   )r‘   r	   ry   rR   Újoinpathrz   r,   s    r   rR   zPath.filenamep  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)NrY   )rv   rŠ   Úread)r&   r'   r(   rt   Ústrms        r   Ú	read_textzPath.read_textt  sR   € Ü!7¸Ð!HÀÑ!HÑˆ�$˜ØˆT�Y‰Y�s˜HÐ6 tÒ6¨vÑ6ð 	¸$Ø—9‘9“;÷	÷ 	ò 	ú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_bytesy  s-   € Ø�Y‰Y�t‹_ð 	 Ø—9‘9“;÷	÷ 	ò 	ús   ’,¬5c                 ó–   — t        j                  |j                  j                  d«      «      | j                  j                  d«      k(  S ©NrL   )r   rN   rz   r   )r&   r   s     r   Ú	_is_childzPath._is_child}  s2   € Ü× Ñ  §¡§¡°Ó!4Ó5¸¿¹¿¹ÈÓ9LÑLÐLr   c                 ó:   — | j                  | j                  |«      S r"   )r)   ry   )r&   rz   s     r   Ú_nextz
Path._next€  s   € Ø�~‰~˜dŸi™i¨Ó,Ð,r   c                 óV   — | j                    xs | j                   j                  d«      S r¦   )rz   rU   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"   )rz   ry   rJ   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†   ÚNotADirectoryErrorr@   r©   ry   rG   Úfilterr§   )r&   Úsubss     r   ÚiterdirzPath.iterdirŒ  sE   € Ø�{‰{Œ}Ü$Ð%;Ó<Ð<Ü�4—:‘:˜tŸy™y×1Ñ1Ó3Ó4ˆÜ�d—n‘n dÓ+Ð+r   c                 ó^   — t        j                  | j                  «      j                  |«      S r"   )r‘   r’   rz   Ú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.
        é   )ry   rS   rz   Ú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: rL   )Úseps)r‹   ÚreÚescaperz   r   ÚcompileÚ	translateÚ	fullmatchr@   r©   r°   ry   rG   )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   ry   rR   rz   r   Újoin)r&   ry   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Ñ   rz   r©   ry   rP   )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¦   )rz   rR   Úparentr   rN   r   r©   )r&   Ú	parent_ats     r   rÚ   zPath.parent¹  sR   € à�wŠwØ—=‘=×'Ñ'Ð'Ü×%Ñ% d§g¡g§n¡n°SÓ&9Ó:ˆ	ÙØ˜ÑˆIØ�z‰z˜)Ó$Ð$r   )Ú )rY   )"r1   r2   r3   r4   rÔ   r%   r~   r�   rŠ   r“   ÚpropertyrM   r—   r™   r›   rR   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"   )r4   rp   rŒ   r   r‘   r   r¿   r¹   rV   Ú
_functoolsr   r   Úcompat.py310r   rÈ   r   Ú__all__r   r   ÚdictÚfromkeysrA   r   r    r[   r8   rh   rv   r	   rß   r   r   ú<module>rå      s�   ðñó Û 	Û Û Û Û 	Û Û ç 1Ý 'Ý àˆ(€ò6ò&,ð6 �-‰-€Ø /òH÷*ñ *ô"EÐ# W§_¡_ô EôP#�ô #ó*>÷
y%ò y%r   