Ë
    Ì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 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é   )Ú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    úN/var/www/html/strategist-ai/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¨�1”y—}‘}Õ$Ñ6ù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ÚlistrC   )r$   r@   r'   s     €r   rE   zCompleteDirs.namelistw   s+   ø€ Ü‘Ñ Ó"ˆØ”t˜D×.Ñ.¨uÓ5Ó6Ñ6Ð6r   c                 ó4   — t        | j                  «       «      S r    )r   rE   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).
        ú/)rH   )r$   Únamer@   Ú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.
        rJ   )Úfilename)r"   ÚgetinfoÚKeyErrorÚendswithrH   ÚzipfileÚZipInfo)r$   rK   r'   s     €r   rQ   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)Ú
isinstancer6   rT   Ú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   )rC   rE   Úwritestr)r[   r^   rK   s      r   ÚinjectzCompleteDirs.inject¦   s7   € ð ×%Ñ% b§k¡k£mÓ4ò 	#ˆDØ�K‰K˜˜cÕ"ð	#àˆ	r   )r/   r0   r1   r2   ÚstaticmethodrC   rE   rH   rN   rQ   Úclassmethodr]   rT   rY   rb   r3   r4   s   @r   r6   r6   f   sn   ø„ ñð ñ4ó ð4ô
7ò$ò.ô	2ð ñó ðð$ ð˜Ÿ™ð ¨G¯O©Oò ó ôr   r6   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   rE   zFastLookup.namelist·   s   € Ø�~‰~Ðr   c                 ó    •— t         ‰| �  «       S r    )r"   rE   ©r$   r'   s    €r   rh   zFastLookup._namelistº   s   ø€ ä‰wÑÓ!Ð!r   c                 ó   — | j                   S r    )Ú_name_set_propr*   s    r   rH   zFastLookup._name_set¾   s   € Ø×"Ñ"Ð"r   c                 ó    •— t         ‰| �  «       S r    )r"   rH   rj   s    €r   rl   zFastLookup._name_set_propÁ   s   ø€ ä‰wÑ Ó"Ð"r   )r/   r0   r1   r2   rE   Ú	functoolsÚcached_propertyrh   rH   rl   r3   r4   s   @r   rf   rf   ±   sF   ø„ ñò
ð ×Ñó"ó ð"ò#ð ×Ñó#ó ô#r   rf   c                 ó’   — t         j                  j                  dk(  }|xr t         j                  dk  }d|z   }t	        | |«      ||fS )NÚpypy)é   é   é   rs   )ÚsysÚimplementationrK   Ú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)rf   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   rW   rˆ   Úbz*encoding args invalid for binary operation)Úis_dirÚIsADirectoryErrorÚexistsÚFileNotFoundErrorr   Úopenr€   Ú
ValueErrorr|   ÚioÚTextIOWrapper)r$   rZ   r‰   r%   r&   Úzip_modeÚstreamrx   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ÚPurePosixPathrP   r*   s    r   Ú_basez
Path._basef  s&   € Ø15·²Œw×$Ñ$ T§W¡WÓ-ÐK¸d¿m¹mÐKr   c                 ó6   — | j                  «       j                  S r    )r™   rK   r*   s    r   rK   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   rP   Újoinpathr€   r*   s    r   rP   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)NrW   )r|   r�   Úread)r$   r%   r&   rx   Ústrms        r   Ú	read_textzPath.read_text}  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_bytes‚  s-   € Ø�Y‰Y�t‹_ð 	 Ø—9‘9“;÷	÷ 	ò 	ús   ’,¬5c                 ó–   — t        j                  |j                  j                  d«      «      | j                  j                  d«      k(  S ©NrJ   )r   rL   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€   rS   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   rH   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   rE   Ú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   rQ   r€   Úexternal_attrÚstatÚS_ISLNK)r$   ÚinforZ   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: rJ   )Úseps)r‘   ÚreÚescaper€   r   ÚcompileÚ	translateÚ	fullmatchr>   r¯   rµ   r   rE   )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                 ój   — t        j                  | j                  j                  | j                  «      S r    )r   Újoinr   rP   r€   r*   s    r   Ú__str__zPath.__str__µ  s!   € Ü�~‰~˜dŸi™i×0Ñ0°$·'±'Ó:Ð:r   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   rN   )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€   rP   Úparentr   rL   r   r¯   )r$   Ú	parent_ats     r   rß   zPath.parentÁ  sR   € à�wŠwØ—=‘=×'Ñ'Ð'Ü×%Ñ% d§g¡g§n¡n°SÓ&9Ó:ˆ	ÙØ˜ÑˆIØ�z‰z˜)Ó$Ð$r   )Ú )rW   )"r/   r0   r1   r2   rÙ   r#   r„   r‡   r�   r™   ÚpropertyrK   r�   rŸ   r¡   rP   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ò;ò-ò7ð €Kàñ%ó ñ%r   r    )r2   rn   r’   r	   r—   r   rÄ   r¾   ru   rT   Ú
_functoolsr   Úcompat.py310r   rÍ   r   Ú__all__r   r   ÚdictÚfromkeysr?   r   r   rY   r6   rf   r|   r   rä   r   r   ú<module>rê      s’   ðñó Û 	Û Û Û Û 	Û Û 
Û å (Ý 'Ý àˆ(€ò6ò&+ð6 �-‰-€Ø /òH÷*ñ *ô"HÐ# W§_¡_ô HôV#�ô #ó*>÷x%ò x%r   