
    h.                        S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
Jr  SSKJr  SSKJr  S/rS rS	 r\R(                  r S
 r " S S5      r " S S\\	R0                  5      r " S S\5      rSS jr " S S5      rg)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                 D    [         R                  " [        U 5      SS5      $ )z
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    E/var/www/auris/envauris/lib/python3.13/site-packages/zipp/__init__.py_parentsr      s      IdOQ55    c              #     #    U R                  [        R                  5      n U R                  [        R                  5      (       aC  U v   [        R                  " U 5      u  pU R                  [        R                  5      (       a  MB  gg7f)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   .   sV     * ;;y}}%D
++imm
$
$
__T*
 ++imm
$
$s   BB
B
c                 V    [         R                  " [        U5      R                  U 5      $ )zN
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                   H   ^  \ rS rSrSr\U 4S j5       rS rU 4S jrSr	U =r
$ )InitializedStateU   z7
Mix-in to save the initialization state for pickling.
c                 &   > [         TU ]  " U0 UD6  g Nsuper__init__)selfargskwargs	__class__s      r   r$   InitializedState.__init__Z   s    $)&)r   c                 Z    U R                   R                  U R                   R                  4$ r!   )_saved___init__r&   r'   r%   s    r   __getstate__InitializedState.__getstate__^   s%    ##(($*>*>*E*EEEr   c                 .   > Uu  p#[         TU ]  " U0 UD6  g r!   r"   )r%   stater&   r'   r(   s       r   __setstate__InitializedState.__setstate__a   s    $)&)r    )__name__
__module____qualname____firstlineno____doc__r   r$   r-   r1   __static_attributes____classcell__r(   s   @r   r   r   U   s,     * *F* *r   r   c                      ^  \ rS rSrSr\S 5       rU 4S jrS rS r	U 4S jr
\S 5       r\S	\R                  S
\R                  4S j5       rSrU =r$ )CompleteDirsf   a  
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                     [         R                  R                  [        [        U 5      5      nS U 5       n[        [        X 5      5      $ )Nc              3   F   #    U  H  o[         R                  -   v   M     g 7fr!   )r   r   ).0ps     r   	<genexpr>-CompleteDirs._implied_dirs.<locals>.<genexpr>t   s     6gy}}$gs   !)r	   chainfrom_iterablemapr   _deduper   )namesparentsas_dirss      r   _implied_dirsCompleteDirs._implied_dirsq   s7    ////He0DE6g6{7233r   c                 Z   > [         TU ]  5       nU[        U R                  U5      5      -   $ r!   )r#   namelistlistrL   )r%   rI   r(   s     r   rO   CompleteDirs.namelistw   s+     "tD..u5666r   c                 4    [        U R                  5       5      $ r!   )r   rO   r,   s    r   	_name_setCompleteDirs._name_set{   s    4==?##r   c                 `    U R                  5       nUS-   nX;  =(       a    X2;   nU(       a  U$ U$ )z`
If the name represents a directory, return that name
as a directory (with the trailing slash).
/)rS   )r%   namerI   dirname	dir_matchs        r   resolve_dirCompleteDirs.resolve_dir~   s6    
  *%:'*:	#w--r   c                    >  [         TU ]  U5      $ ! [         aA    UR                  S5      (       a  XR	                  5       ;  a  e [
        R                  " US9s $ f = f)z&
Supplement getinfo for implied dirs.
rV   )filename)r#   getinfoKeyErrorendswithrS   zipfileZipInfo)r%   rW   r(   s     r   r^   CompleteDirs.getinfo   sS    	27?4(( 	2==%%^^5E)E??D11	2s    AAAc                     [        U[        5      (       a  U$ [        U[        R                  5      (       d  U " U5      $ SUR                  ;  a  [        n Xl        U$ )zT
Given a source (filename or zipfile), return an
appropriate CompleteDirs subclass.
r)
isinstancer=   ra   ZipFilemoder(   )clssources     r   makeCompleteDirs.make   sO     fl++M&'//22v; fkk!Cr   zfreturnc                 v    U R                  UR                  5       5       H  nUR                  US5        M     U$ )zq
Given a writable zip file zf, inject directory entries for
any directories implied by the presence of children.
r   )rL   rO   writestr)ri   rm   rW   s      r   injectCompleteDirs.inject   s2     %%bkkm4DKKc" 5	r   r3   )r4   r5   r6   r7   r8   staticmethodrL   rO   rS   rZ   r^   classmethodrk   ra   rg   rq   r9   r:   r;   s   @r   r=   r=   f   sn     4 4
7$.	2  $  GOO  r   r=   c                      ^  \ rS rSrSrS r\R                  U 4S j5       rS r	\R                  U 4S j5       r
SrU =r$ )
FastLookup   zJ
ZipFile subclass to ensure implicit
dirs exist and are resolved rapidly.
c                     U R                   $ r!   )	_namelistr,   s    r   rO   FastLookup.namelist   s    ~~r   c                     > [         TU ]  5       $ r!   )r#   rO   r%   r(   s    r   ry   FastLookup._namelist   s    w!!r   c                     U R                   $ r!   )_name_set_propr,   s    r   rS   FastLookup._name_set   s    """r   c                     > [         TU ]  5       $ r!   )r#   rS   r|   s    r   r   FastLookup._name_set_prop   s    w ""r   r3   )r4   r5   r6   r7   r8   rO   	functoolscached_propertyry   rS   r   r9   r:   r;   s   @r   rv   rv      sF    
 " "# # #r   rv   c                     [         R                  R                  S:H  nU=(       a    [         R                  S:  nSU-   n[	        X5      X4$ )Npypy)         r   )sysimplementationrW   pypy_version_infor   )encodingr&   r'   is_pypyis_old_pypistack_levels         r   _extract_text_encodingr      sH      %%/G @c33j@Kk/K/==r   c                      \ rS rSrSrSrS"S jrS rS rS#SS.S	 jjr	S
 r
\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r \ r!\S  5       r"S!r#g)$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                 D    [         R                  U5      U l        X l        g)a   
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)rv   rk   rootat)r%   r   r   s      r   r$   Path.__init__9  s     OOD)	r   c                     U R                   UR                   La  [        $ U R                  U R                  4UR                  UR                  4:H  $ )z=
>>> Path(zipfile.ZipFile(io.BytesIO(), 'w')) == 'foo'
False
)r(   NotImplementedr   r   )r%   others     r   __eq__Path.__eq__F  s?    
 >>0!!		477#

EHH'===r   c                 D    [        U R                  U R                  45      $ r!   )hashr   r   r,   s    r   __hash__Path.__hash__O  s    TYY())r   Npwdc                r   U R                  5       (       a  [        U 5      eUS   nUS:X  a   U R                  5       (       d  [        U 5      eU R                  R                  U R                  XRS9nSU;   a  U(       d  U(       a  [        S5      eU$ [        U0 UD6u  psn[        R                  " Xg/UQ70 UD6$ )z
Open this entry as text or binary following the semantics
of ``pathlib.Path.open()`` by passing arguments through
to io.TextIOWrapper().
r   re   r   bz*encoding args invalid for binary operation)is_dirIsADirectoryErrorexistsFileNotFoundErrorr   openr   
ValueErrorr   ioTextIOWrapper)r%   rh   r   r&   r'   zip_modestreamr   s           r   r   	Path.openR  s     ;;==#D))7s?4;;==#D));$;v !MNNM!7!H!HB4B6BBr   c                 |    U R                   (       a   [        R                  " U R                   5      $ U R                  $ r!   )r   pathlibPurePosixPathr]   r,   s    r   _base
Path._basef  s&    15w$$TWW-KdmmKr   c                 6    U R                  5       R                  $ r!   )r   rW   r,   s    r   rW   	Path.namei      zz|   r   c                 6    U R                  5       R                  $ r!   )r   suffixr,   s    r   r   Path.suffixm  s    zz|"""r   c                 6    U R                  5       R                  $ r!   )r   suffixesr,   s    r   r   Path.suffixesq  s    zz|$$$r   c                 6    U R                  5       R                  $ r!   )r   stemr,   s    r   r   	Path.stemu  r   r   c                     [         R                  " U R                  R                  5      R	                  U R
                  5      $ r!   )r   r   r   r]   joinpathr   r,   s    r   r]   Path.filenamey  s*    ||DII../88AAr   c                     [        U0 UD6u  p1nU R                  " SU/UQ70 UD6 nUR                  5       sS S S 5        $ ! , (       d  f       g = f)Nre   )r   r   read)r%   r&   r'   r   strms        r   	read_textPath.read_text}  sE    !7!H!HYYsH6t6v6$99; 766s   A  
Ac                 z    U R                  S5       nUR                  5       sS S S 5        $ ! , (       d  f       g = f)Nrb)r   r   )r%   r   s     r   
read_bytesPath.read_bytes  s"    YYt_99; __s   ,
:c                     [         R                  " UR                  R                  S5      5      U R                  R                  S5      :H  $ NrV   )r   rX   r   r   )r%   r   s     r   	_is_childPath._is_child  s2      !459LLLr   c                 :    U R                  U R                  U5      $ r!   )r(   r   )r%   r   s     r   _next
Path._next  s    ~~dii,,r   c                 h    U R                   (       + =(       d    U R                   R                  S5      $ r   )r   r`   r,   s    r   r   Path.is_dir  s"    77{3dgg..s33r   c                 Z    U R                  5       =(       a    U R                  5       (       + $ r!   )r   r   r,   s    r   is_filePath.is_file  s    {{}2T[[]!22r   c                 P    U R                   U R                  R                  5       ;   $ r!   )r   r   rS   r,   s    r   r   Path.exists  s    ww$))--///r   c                     U R                  5       (       d  [        S5      e[        U R                  U R                  R                  5       5      n[        U R                  U5      $ )NzCan't listdir a file)r   r   rG   r   r   rO   filterr   )r%   subss     r   iterdirPath.iterdir  sG    {{}}3444::tyy1134dnnd++r   c                 `    [         R                  " U R                  5      R                  U5      $ r!   )r   r   r   match)r%   path_patterns     r   r   
Path.match  s"    $$TWW-33LAAr   c                     U R                   R                  U R                  5      nUR                  S-	  n[        R
                  " U5      $ )z(
Return whether this path is a symlink.
   )r   r^   r   external_attrstatS_ISLNK)r%   inforh   s      r   
is_symlinkPath.is_symlink  s;     yy  )!!R'||D!!r   c                 P   U(       d  [        SU< 35      e[        R                  " U R                  5      n[	        SS9n[        R
                  " X#R                  U5      -   5      R                  n[        U R                  [        X@R                  R                  5       5      5      $ )NzUnacceptable pattern: rV   )seps)r   reescaper   r   compile	translate	fullmatchrG   r   r   r   rO   )r%   patternprefixtrmatchess        r   glob	Path.glob  sw    5g[ABB477#S!**Vll7&;;<FF4::vgyy/A/A/CDEEr   c                 *    U R                  SU 35      $ )Nz**/)r   )r%   r   s     r   rglob
Path.rglob  s    yy3wi))r   c                 n    [         R                  " [        U 5      [        UR                  " U6 5      5      $ r!   )r   relpathstrr   )r%   r   extras      r   relative_toPath.relative_to  s'      TC0F,GHHr   c                 l    [         R                  " U R                  R                  U R                  5      $ r!   )r   joinr   r]   r   r,   s    r   __str__Path.__str__  s!    ~~dii00$''::r   c                 4    U R                   R                  U S9$ )Nr,   )_Path__reprformatr,   s    r   __repr__Path.__repr__  s    {{!!t!,,r   c                     [         R                  " U R                  /UQ76 nU R                  U R                  R                  U5      5      $ r!   )r   r  r   r   r   rZ   )r%   r   nexts      r   r   Path.joinpath  s7    ~~dgg..zz$))//566r   c                     U R                   (       d  U R                  R                  $ [        R                  " U R                   R                  S5      5      nU(       a  US-  nU R                  U5      $ r   )r   r]   parentr   rX   r   r   )r%   	parent_ats     r   r  Path.parent  sR    ww=='''%%dggnnS&9:	Izz)$$r   )r   r   ) )re   )$r4   r5   r6   r7   r8   r  r$   r   r   r   r   propertyrW   r   r   r   r]   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r   __truediv__r  r9   r3   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!   )r8   r   r   r	   r   r   r   r   r   ra   
_functoolsr   compat.py310r   r   r   __all__r   r   dictfromkeysrH   r   r   rg   r=   rv   r   r   r3   r   r   <module>r     s     	    	  
  ( ' (6&+6 -- /H* *"H#W__ HV# #*>x% x%r   