+
     Bi.                        R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^RI
Ht R.tR tR t]P                   t R t ! R R4      t ! R	 R
]]	P(                  4      t ! R R]4      tRR lt ! R R4      tR# )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)
TranslatorPathc                D    \         P                  ! \        V 4      ^R4      # )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(''))
[]
N)	itertoolsislice	_ancestry)paths   &-/usr/lib/python3.14/zipfile/_path/__init__.py_parentsr
      s      IdOQ55    c              #     "   V P                  \        P                  4      p V P                  \        P                  4      '       d   V x  \        P                  ! V 4      w  rKC  R# 5i)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   ,   sH     * ;;y}}%D
++imm
$
$
__T*
d %s   AA' A'c                V    \         P                  ! \        V4      P                  V 4      # )zN
Return items in minuend not in subtrahend, retaining order
with O(1) lookup.
)r   filterfalseset__contains__)minuend
subtrahends   &&r	   _differencer   K   s!    
   Z!=!=wGGr   c                   H   a a ] tR t^St oRtV 3R ltR tV 3R ltRtVt	V ;t
# )InitializedStatez7
Mix-in to save the initialization state for pickling.
c                @   < Wn         W n        \        SV `  ! V/ VB  R # N)_InitializedState__args_InitializedState__kwargssuper__init__)selfargskwargs	__class__s   &*,r	   r    InitializedState.__init__X   s    $)&)r   c                2    V P                   V P                  3# r   )r   r   r!   s   &r	   __getstate__InitializedState.__getstate__]   s    {{DMM))r   c                0   < Vw  r#\         SV `  ! V/ VB  R # r   )r   r    )r!   stater"   r#   r$   s   &&  r	   __setstate__InitializedState.__setstate__`   s    $)&)r   )__args__kwargs)__name__
__module____qualname____firstlineno____doc__r    r(   r,   __static_attributes____classdictcell____classcell__r$   __classdict__s   @@r	   r   r   S   s     *
** *r   r   c                      a a ] tR t^et oRt]R 4       tV 3R ltR tR t	V 3R lt
]R 4       t]V3R lR	 l4       tR
tVtV ;t# )CompleteDirsa  
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                    \         P                  P                  \        \        V 4      4      pR  V 4       p\        \        W 4      4      # )c              3   N   "   T F  q\         P                  ,           x  K  	  R # 5ir   )r   r   ).0ps   & r	   	<genexpr>-CompleteDirs._implied_dirs.<locals>.<genexpr>s   s     6gy}}$$gs   #%)r   chainfrom_iterablemapr
   _deduper   )namesparentsas_dirss   &  r	   _implied_dirsCompleteDirs._implied_dirsp   s7    ////He0DE6g6{7233r   c                b   < \         SV `  4       pV\        V P                  V4      4      ,           # r   )r   namelistlistrI   )r!   rF   r$   s   & r	   rL   CompleteDirs.namelistv   s+     "tD..u5666r   c                4    \        V P                  4       4      # r   )r   rL   r'   s   &r	   	_name_setCompleteDirs._name_setz   s    4==?##r   c                l    V P                  4       pVR,           pW9  ;'       d    W29   pV'       d   V# T# )z`
If the name represents a directory, return that name
as a directory (with the trailing slash).
/)rP   )r!   namerF   dirname	dir_matchs   &&   r	   resolve_dirCompleteDirs.resolve_dir}   s9    
  *%::'*:	#w--r   c                   <  \         SV `  V4      #   \         dG    TP                  R4      '       d   YP	                  4       9  d   h \
        P                  ! TR7      u # i ; i)z&
Supplement getinfo for implied dirs.
rS   )filename)r   getinfoKeyErrorendswithrP   zipfileZipInfo)r!   rT   r$   s   &&r	   r[   CompleteDirs.getinfo   sS    	27?4(( 	2==%%^^5E)E??D11	2s    !A#,A#"A#c                    \        V\        4      '       d   V# \        V\        P                  4      '       g	   V ! V4      # RVP                  9  d   \        p Wn        V# )zT
Given a source (filename or zipfile), return an
appropriate CompleteDirs subclass.
r)
isinstancer;   r^   ZipFilemoder$   )clssources   &&r	   makeCompleteDirs.make   sO     fl++M&'//22v; fkk!Cr   c                N   < V ^8  d   QhRS[ P                  RS[ P                  /# )   zfreturn)r^   rd   )formatr9   s   "r	   __annotate__CompleteDirs.__annotate__   s#       GOO r   c                v    V P                  VP                  4       4       F  pVP                  VR4       K  	  V# )zq
Given a writable zip file zf, inject directory entries for
any directories implied by the presence of children.
r   )rI   rL   writestr)rf   rl   rT   s   && r	   injectCompleteDirs.inject   s2     %%bkkm4DKKc" 5	r    )r0   r1   r2   r3   r4   staticmethodrI   rL   rP   rW   r[   classmethodrh   rs   r5   r6   r7   r8   s   @@r	   r;   r;   e   s_      4 4
7$.	2  $   r   r;   c                   B   a a ] tR t^t oRtV 3R ltV 3R ltRtVtV ;t	# )
FastLookupzJ
ZipFile subclass to ensure implicit
dirs exist and are resolved rapidly.
c                   < \         P                  ! \        4      ;_uu_ 4        V P                  uuR R R 4       #   + '       g   i     M; i\        ST `  4       T n        T P                  # r   )
contextlibsuppressAttributeError_FastLookup__namesr   rL   r!   r$   s   &r	   rL   FastLookup.namelist   sC      00<< 1000w')||	   ;A	c                   < \         P                  ! \        4      ;_uu_ 4        V P                  uuR R R 4       #   + '       g   i     M; i\        ST `  4       T n        T P                  # r   )r{   r|   r}   _FastLookup__lookupr   rP   r   s   &r	   rP   FastLookup._name_set   sC      00== 1000)+}}r   )__lookup__names)
r0   r1   r2   r3   r4   rL   rP   r5   r6   r7   r8   s   @@r	   ry   ry      s     
 r   ry   c                     \         P                  P                  R 8H  pT;'       d    \         P                  R8  p^V,           p\        P
                  ! W4      W3# )pypy)         )sysimplementationrT   pypy_version_infoiotext_encoding)encodingr"   r#   is_pypyis_old_pypistack_levels   &*,   r	   _extract_text_encodingr      sQ      %%/G @@c33j@Kk/KH2D@@r   c                     a  ] tR t^t o RtRtR!R ltR tR tR"RR/R llt	R	 t
]R
 4       t]R 4       t]R 4       t]R 4       t]R 4       tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t ] t!]R 4       t"R t#V t$R# )#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(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    \         P                  V4      V n        W n        R# )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)ry   rh   rootat)r!   r   r   s   &&&r	   r    Path.__init__5  s     OOD)	r   c                    V P                   VP                   Jd   \        # V P                  V P                  3VP                  VP                  38H  # )z=
>>> Path(zipfile.ZipFile(io.BytesIO(), 'w')) == 'foo'
False
)r$   NotImplementedr   r   )r!   others   &&r	   __eq__Path.__eq__B  s?    
 >>0!!		477#

EHH'===r   c                D    \        V P                  V P                  34      # r   )hashr   r   r'   s   &r	   __hash__Path.__hash__K  s    TYY())r   pwdNc                  V P                  4       '       d   \        V 4      hV^ ,          pVR8X  d"   V P                  4       '       g   \        V 4      hV P                  P                  V P                  WRR7      pRV9   d   V'       g	   V'       d   \        R4      hV# \        V/ VB w  rsp\        P                  ! Wg.VO5/ VB # )z
Open this entry as text or binary following the semantics
of ``pathlib.Path.open()`` by passing arguments through
to io.TextIOWrapper().
rb   )r   bz*encoding args invalid for binary operation)is_dirIsADirectoryErrorexistsFileNotFoundErrorr   openr   
ValueErrorr   r   TextIOWrapper)r!   re   r   r"   r#   zip_modestreamr   s   &&$*,   r	   r   	Path.openN  s     ;;==#D))7s?4;;==#D));$;v !MNNM!7!H!HB4B6BBr   c                ~    V P                   '       d!   \        P                  ! V P                   4      # V P                  # r   )r   pathlibPurePosixPathrZ   r'   s   &r	   _base
Path._baseb  s(    15w$$TWW-KdmmKr   c                6    V P                  4       P                  # r   )r   rT   r'   s   &r	   rT   	Path.namee      zz|   r   c                6    V P                  4       P                  # r   )r   suffixr'   s   &r	   r   Path.suffixi  s    zz|"""r   c                6    V P                  4       P                  # r   )r   suffixesr'   s   &r	   r   Path.suffixesm  s    zz|$$$r   c                6    V P                  4       P                  # r   )r   stemr'   s   &r	   r   	Path.stemq  r   r   c                    \         P                  ! V P                  P                  4      P	                  V P
                  4      # r   )r   r   r   rZ   joinpathr   r'   s   &r	   rZ   Path.filenameu  s*    ||DII../88AAr   c                    \        V/ VB w  r1pV P                  ! R V.VO5/ VB ;_uu_ 4       pVP                  4       uuRRR4       #   + '       g   i     R# ; i)rb   N)r   r   read)r!   r"   r#   r   strms   &*,  r	   	read_textPath.read_texty  sK    !7!H!HYYsH6t6v66$99; 7666s   A		A	c                    V P                  R 4      ;_uu_ 4       pVP                  4       uuRRR4       #   + '       g   i     R# ; i)rbN)r   r   )r!   r   s   & r	   
read_bytesPath.read_bytes~  s&    YYt__99; ___s	   5A	c                    \         P                  ! VP                  P                  R 4      4      V P                  P                  R 4      8H  # rS   )r   rU   r   r   )r!   r   s   &&r	   	_is_childPath._is_child  s2      !459LLLr   c                :    V P                  V P                  V4      # r   )r$   r   )r!   r   s   &&r	   _next
Path._next  s    ~~dii,,r   c                j    V P                   '       * ;'       g    V P                   P                  R 4      # r   )r   r]   r'   s   &r	   r   Path.is_dir  s%    77{33dgg..s33r   c                \    V P                  4       ;'       d    V P                  4       '       * # r   )r   r   r'   s   &r	   is_filePath.is_file  s    {{}22T[[]!22r   c                P    V P                   V P                  P                  4       9   # r   )r   r   rP   r'   s   &r	   r   Path.exists  s    ww$))--///r   c                    V P                  4       '       g   \        R 4      h\        V P                  V P                  P                  4       4      p\        V P                  V4      # )zCan't listdir a file)r   r   rD   r   r   rL   filterr   )r!   subss   & r	   iterdirPath.iterdir  sG    {{}}3444::tyy1134dnnd++r   c                `    \         P                  ! V P                  4      P                  V4      # r   )r   r   r   match)r!   path_patterns   &&r	   r   
Path.match  s"    $$TWW-33LAAr   c                    V P                   P                  V P                  4      pVP                  ^,	          p\        P
                  ! V4      # )z(
Return whether this path is a symlink.
)r   r[   r   external_attrstatS_ISLNK)r!   infore   s   &  r	   
is_symlinkPath.is_symlink  s;     yy  )!!R'||D!!r   c                `   V'       g   \        R V: 24      h\        P                  ! V P                  4      p\	        RR7      p\        P
                  ! W#P                  V4      ,           4      P                  p\        V P                  \        W@P                  P                  4       4      4      # )zUnacceptable pattern: rS   )seps)r   reescaper   r   compile	translate	fullmatchrD   r   r   r   rL   )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                *    V P                  R V 24      # )z**/)r   )r!   r   s   &&r	   rglob
Path.rglob  s    yy3wi))r   c           	     p    \         P                  ! \        V 4      \        VP                  ! V!  4      4      # r   )r   relpathstrr   )r!   r   extras   &&*r	   relative_toPath.relative_to  s'      TC0F,GHHr   c                l    \         P                  ! V P                  P                  V P                  4      # r   )r   joinr   rZ   r   r'   s   &r	   __str__Path.__str__  s!    ~~dii00$''::r   c                :    V P                   P                  V R 7      # )r'   )_Path__reprrn   r'   s   &r	   __repr__Path.__repr__  s    {{!!t!,,r   c                    \         P                  ! V P                  .VO5!  pV P                  V P                  P                  V4      4      # r   )r   r  r   r   r   rW   )r!   r   nexts   &* r	   r   Path.joinpath  s7    ~~dgg..zz$))//566r   c                    V P                   '       g   V P                  P                  # \        P                  ! V P                   P                  R 4      4      pV'       d
   VR ,          pV P                  V4      # r   )r   rZ   parentr   rU   r   r   )r!   	parent_ats   & r	   r  Path.parent  sT    www=='''%%dggnnS&9:	Izz)$$r   )r   r   ) )rb   )%r0   r1   r2   r3   r4   r  r    r   r   r   r   propertyrT   r   r   r   rZ   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   __truediv__r  r5   r6   )r9   s   @r	   r   r      s
    dL NF>*C C(L ! ! # # % % ! ! B B
M-430,B"F*I;-7 K% %r   r   )r4   r{   r   r   r   r   r   r   r   r^   r   r   __all__r
   r   dictfromkeysrE   r   r   rd   r;   ry   r   r   ru   r   r	   <module>r     s     	    	  
  (6&+6 -- /H* *$H#W__ HV $Ax% x%r   