+
    BiD*                        R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHtHtHtH	t	 ^RI
Ht ]'       d   ^ RIHtHtHt M
^ RIHtHtHt  ! R R4      t ! R R]4      t]! 4       t ! R	 R
]4      t ! R R4      t ! R R]4      t ! R R]4      tR# )z
Implementations of ReadablePath and WritablePath for zip file members, for use
in pathlib tests.

ZipPathGround is also defined here. It helps establish the "ground truth"
about zip file members in tests.
N)S_IFMTS_ISDIRS_ISREGS_ISLNK)is_pypi)PathInfo_ReadablePath_WritablePathc                   x   a  ] tR t^t o RtR tRR ltR tRR ltR t	R t
R tR	 tR
 t]tR tR tR tRtV tR# )ZipPathGroundTc                    Wn         R # Npath_cls)selfr   s   &&9/usr/lib/python3.14/test/test_pathlib/support/zip_path.py__init__ZipPathGround.__init__   s         c                v    V P                  \        P                  ! \        P                  ! 4       R 4      R7      # )wzip_file)r   zipfileZipFileioBytesIO)r   local_suffixs   &&r   setupZipPathGround.setup   s$    }}goobjjlC&H}IIr   c                :    VP                   P                  4        R # r   )r   close)r   roots   &&r   teardownZipPathGround.teardown!   s    r   c                P    VP                   P                  \        V4      V4       R # r   )r   writestrstr)r   pathdatas   &&&r   create_fileZipPathGround.create_file$   s    s4y$/r   c                4   \         P                  ! \        V4      R ,           4      pV;P                  \        P
                  ^,          ,          un        V;P                  \        P                  ,          un        VP                  P                  VR4       R# / N	r   ZipInfor'   external_attrstatS_IFDIRFILE_ATTRIBUTE_DIRECTORYr   r&   )r   r(   zip_infos   && r   
create_dirZipPathGround.create_dir'   s]    ??3t9s?3$,,""44$"?"??x,r   c                    \         P                  ! \        V4      4      p\        P                  ^,          Vn        VP                  P                  W2P                  4       4       R#    N)	r   r1   r'   r3   S_IFLNKr2   r   r&   encode)r   r(   targetr6   s   &&& r   create_symlinkZipPathGround.create_symlink-   s=    ??3t9-!%!3x9r   c                   V P                  VP                  R 4      R4       V P                  VP                  R4      R4       V P                  VP                  R4      R4       V P                  VP                  R4      R4       V P                  VP                  R4      R	4       V P                  VP                  R
4      R 4       V P                  VP                  R4      R4       V P                  VP                  R4      R4       V P                  VP                  R4      R4       V P                  VP                  R4      R4       R# )fileAs   this is file A
z
dirB/fileBs   this is file B
z
dirC/fileCs   this is file C
zdirC/dirD/fileDs   this is file D
zdirC/novel.txts   this is a novel
linkAlinkBdirBz
dirA/linkCz../dirB
brokenLinkznon-existingbrokenLinkLoopN)r*   joinpathr?   )r   ps   &&r   create_hierarchyZipPathGround.create_hierarchy2   s   G,.ABL13FGL13FG$568KL$457KLAJJw/9AJJw/8AJJ|4i@AJJ|4nEAJJ'78:JKr   c                    VP                   P                  \        V4      R 4      ;_uu_ 4       p\        P                  ! VRR7      pVP                  4       uuRRR4       #   + '       g   i     R# ; i)rzutf-8)encodingN)r   openr'   r   TextIOWrapperreadr   rI   fs   && r   readtextZipPathGround.readtext@   sG    ZZ__SVS))Q  W5A668 *)))s   (A!!A2	c                    VP                   P                  \        V4      R 4      ;_uu_ 4       pVP                  4       uuRRR4       #   + '       g   i     R# ; i)rM   N)r   rO   r'   rQ   rR   s   && r   	readbytesZipPathGround.readbytesE   s5    ZZ__SVS))Q668 *)))s   A		A	c                V    \        V4      R ,           pW!P                  P                  9   # )r.   )r'   r   
NameToInfo)r   rI   path_strs   && r   isdirZipPathGround.isdirK   s"    q6C<::0000r   c                    VP                   P                  P                  \        V4      4      pVf   R# \        P
                  ! VP                  ^,	          4      '       * # NFr   rZ   getr'   r3   r   r2   r   rI   infos   && r   isfileZipPathGround.isfileO   sE    zz$$((Q0<<< 2 2b 8999r   c                    VP                   P                  P                  \        V4      4      pVf   R# \        P
                  ! VP                  ^,	          4      # r_   r`   rb   s   && r   islinkZipPathGround.islinkU   sB    zz$$((Q0<||D.."455r   r   Nr/   )r   )__name__
__module____qualname____firstlineno__can_symlinkr   r   r#   r*   r7   r?   rJ   rT   rW   readlinkr\   rd   rg   __static_attributes____classdictcell____classdict__s   @r   r   r      sT     K!J0-:
L
 H1:6 6r   r   c                   R   a  ] tR t^\t o RtRtR	R ltR	R ltR	R ltR t	R t
RtV tR# )
MissingZipPathInfozI
PathInfo implementation that is used when a zip file member is missing.
c                    R # F r   follow_symlinkss   &&r   existsMissingZipPathInfo.existsb       r   c                    R # rw   rx   ry   s   &&r   is_dirMissingZipPathInfo.is_dire   r}   r   c                    R # rw   rx   ry   s   &&r   is_fileMissingZipPathInfo.is_fileh   r}   r   c                    R # rw   rx   r   s   &r   
is_symlinkMissingZipPathInfo.is_symlinkk   r}   r   c                    V # r   rx   r   s   &r   resolveMissingZipPathInfo.resolven   s    r   rx   NT)rj   rk   rl   rm   __doc__	__slots__r{   r   r   r   r   rp   rq   rr   s   @r   ru   ru   \   s/      I r   ru   c                   `   a  ] tR t^ut o RtR
tRR ltRR ltRR ltRR lt	R t
RR ltR	tV tR# )ZipPathInfoz:
PathInfo implementation for an existing zip file member.
Nc                P    Wn         R V n        T;'       g    T V n        / V n        R # r   r   r6   parentchildren)r   r   r   s   &&&r   r   ZipPathInfo.__init__{   s"     nnr   c                ~    V'       d5   V P                  4       '       d   V P                  4       P                  4       # R # r   )r   r   r{   ry   s   &&r   r{   ZipPathInfo.exists   s)    t00<<>((**r   c                V   V'       d5   V P                  4       '       d   V P                  4       P                  4       # V P                  f   R# \	        V P                  P
                  ^,	          4      ;p'       d   \        V4      # V P                  P                  P                  R4      # )NTr.   )	r   r   r   r6   r   r2   r   filenameendswithr   rz   fmts   && r   r   ZipPathInfo.is_dir   sw    t00<<>((**]]"4==66"<==S=3<==))22377r   c                `   V'       d5   V P                  4       '       d   V P                  4       P                  4       # V P                  f   R# \	        V P                  P
                  ^,	          4      ;p'       d   \        V4      # V P                  P                  P                  R4      '       * # )NFr.   )	r   r   r   r6   r   r2   r   r   r   r   s   && r   r   ZipPathInfo.is_file   sz    t00<<>))++]]"4==66"<==S=3<}}--66s;;;r   c                    V P                   f   R# \        V P                   P                  ^,	          4      ;p'       d   \        V4      # R# r_   )r6   r   r2   r   )r   r   s   & r   r   ZipPathInfo.is_symlink   s;    == 4==66"<==S=3<r   c                   ^ pV'       d   VP                  R4      RRR1,          M. pT p VP                  4       '       d   V'       g	   V'       d   V^,          pV^(8  d   \        # VP                  P	                  VP
                  4      P                  4       pYQ'       d   VP                  R4      RRR1,          M. ,          pVP                  pV'       d   VP                  4       pMV# VR8X  d   VP                  pK  V'       g   K  VR8w  g   K  WvP                  9  d3   V'       d%   \        VP                  V4      VP                  V&   M\        # VP                  V,          pEKB  )a  
Traverse zip hierarchy (parents, children and symlinks) starting
from this PathInfo. This is called from three places:

- When a zip file member is added to ZipFile.filelist, this method
  populates the ZipPathInfo tree (using create=True).
- When ReadableZipPath.info is accessed, this method is finds a
  ZipPathInfo entry for the path without resolving any final symlink
  (using follow_symlinks=False)
- When ZipPathInfo methods are called with follow_symlinks=True, this
  method resolves any symlink in the final path position.
r.   Nz...)splitr   missing_zip_path_infor   rQ   r6   decoder   popr   r   )r   r(   createrz   
link_countstackrc   names   &&&&    r   r   ZipPathInfo.resolve   s    
)-

3"%2  oa
#00}}))$--8??A$C2.B>{{yy{t|{{$#+}},.9$--.Nd+44}}T*r   )r   r   r   r6   r   r   r   )NFT)rj   rk   rl   rm   r   r   r   r{   r   r   r   r   rp   rq   rr   s   @r   r   r   u   s4      ?I
8<&+ &+r   r   c                   @   a  ] tR t^t o RtRtR tR tR tR t	Rt
V tR# )	ZipFileListz
`list`-like object that we inject as `ZipFile.filelist`. We maintain a
tree of `ZipPathInfo` objects representing the zip file members.
c                |    \        V4      V n        . V n        VP                   F  pV P	                  V4       K  	  R # r   )r   tree_itemsfilelistappend)r   r   items   && r   r   ZipFileList.__init__   s1    )	%%DKK &r   c                ,    \        V P                  4      # r   )lenr   r   s   &r   __len__ZipFileList.__len__   s    4;;r   c                ,    \        V P                  4      # r   )iterr   r   s   &r   __iter__ZipFileList.__iter__   s    DKK  r   c                    V P                   P                  V4       WP                  P                  VP                  R R7      n        R# )T)r   N)r   r   r   r   r   r6   )r   r   s   &&r   r   ZipFileList.append   s2    4 AE		$--5>r   )r   r   N)r   r   )rj   rk   rl   rm   r   r   r   r   r   r   rp   rq   rr   s   @r   r   r      s,     
 #I !F Fr   r   c                   v   a  ] tR t^t o RtRt]tR tR t	R t
R tR tR t]R 4       tRR	 ltR
 tR tRtV tR# )ReadableZipPathz?
Simple implementation of a ReadablePath class for .zip files.
c                   W n         Wn        \        VP                  \        4      '       g   \	        V4      Vn        R # R # r   )	_segmentsr   
isinstancer   r   r   r   pathsegmentss   &$*r   r   ReadableZipPath.__init__   s1    % (++[99 +H 5H :r   c                B    \        \        V 4      V P                  34      # r   hashr'   r   r   s   &r   __hash__ReadableZipPath.__hash__       SY.//r   c                    \        V\        4      '       g   \        # \        V 4      \        V4      8H  ;'       d    V P                  VP                  J # r   )r   r   NotImplementedr'   r   r   others   &&r   __eq__ReadableZipPath.__eq__   =    %11!!4yCJ&JJ4==ENN+JJr   c                r    V P                   '       g   R # V P                  P                  ! V P                   !  # ri   r   parserjoinr   s   &r   __str__ReadableZipPath.__str__   '    ~~~{{00r   c                h    \        V 4      P                   R \        V 4      : RV P                  : R2# (z, zip_file=)typerj   r'   r   r   s   &r   __repr__ReadableZipPath.__repr__   0    t*%%&aD	}K?PPQRRr   c                8    \        V 4      ! VR V P                  / # r   r   r   r   r   s   &*r   with_segmentsReadableZipPath.with_segments      Dz<@$--@@r   c                z    V P                   P                  P                  pVP                  \	        V 4      R R7      # )F)rz   )r   r   r   r   r'   )r   r   s   & r   rc   ReadableZipPath.info  s.    }}%%**||CIu|==r   c                F   V P                   P                  4       pVP                  4       '       g   \        \        P
                  R V 4      hVP                  4       '       d   \        \        P                  RV 4      hV P                  P                  VP                  R4      # )File not foundzIs a directoryrM   )rc   r   r{   FileNotFoundErrorerrnoENOENTr   IsADirectoryErrorEISDIRr   rO   r6   )r   	bufferingrc   s   && r   __open_rb__ReadableZipPath.__open_rb__
  sm    yy  "{{}}#ELL2BDII[[]]#ELL2BDII}}!!$--55r   c                (  a  S P                   P                  4       pVP                  4       '       g   \        \        P
                  R S 4      hVP                  4       '       g   \        \        P                  RS 4      hV 3R lVP                   4       # )r   zNot a directoryc              3   6   <"   T F  pSV,          x  K  	  R # 5ir   rx   ).0r   r   s   & r   	<genexpr>*ReadableZipPath.iterdir.<locals>.<genexpr>  s     6ts   )
rc   r   r{   r   r   r   r   NotADirectoryErrorENOTDIRr   r   rc   s   f r   iterdirReadableZipPath.iterdir  sb    yy  "{{}}#ELL2BDII$U]]4EtLL666r   c                b   V P                   pVP                  4       '       g   \        \        P                  R V 4      hVP                  4       '       g   \        \        P                  RV 4      hV P                  V P                  P                  VP                  4      P                  4       4      # )r   zNot a symlink)rc   r{   r   r   r   r   OSErrorEINVALr   r   rQ   r6   r   r   s   & r   ro   ReadableZipPath.readlink  sw    yy{{}}#ELL2BDII""%,,>>!!$--"4"4T]]"C"J"J"LMMr   r   r   Nr   )rj   rk   rl   rm   r   r   	posixpathr   r   r   r   r   r   r   propertyrc   r   r   ro   rp   rq   rr   s   @r   r   r      sa      *IF60K
1
SA > >67N Nr   r   c                   n   a  ] tR tRt o RtRt]tR tR t	R t
R tR tR tRR	 ltRR
 ltRR ltRtV tR# )WritableZipPathi#  z?
Simple implementation of a WritablePath class for .zip files.
c                   W n         Wn        R # r   r  r   s   &$*r   r   WritableZipPath.__init__+  s    % r   c                B    \        \        V 4      V P                  34      # r   r   r   s   &r   r   WritableZipPath.__hash__/  r   r   c                    \        V\        4      '       g   \        # \        V 4      \        V4      8H  ;'       d    V P                  VP                  J # r   )r   r
  r   r'   r   r   s   &&r   r   WritableZipPath.__eq__2  r   r   c                r    V P                   '       g   R # V P                  P                  ! V P                   !  # ri   r   r   s   &r   r   WritableZipPath.__str__7  r   r   c                h    \        V 4      P                   R \        V 4      : RV P                  : R2# r   r   r   s   &r   r   WritableZipPath.__repr__<  r   r   c                8    \        V 4      ! VR V P                  / # r   r   r   s   &*r   r   WritableZipPath.with_segments?  r   r   c                L    V P                   P                  \        V 4      R 4      # )r   )r   rO   r'   )r   r   s   &&r   __open_wb__WritableZipPath.__open_wb__B  s    }}!!#d)S11r   c                4   \         P                  ! \        V 4      R ,           4      pV;P                  \        P
                  ^,          ,          un        V;P                  \        P                  ,          un        V P                  P                  VR4       R# r-   r0   )r   modezinfos   && r   mkdirWritableZipPath.mkdirE  s]    D	C0t||r11t<<<ub)r   c                   \         P                  ! \        V 4      4      p\        P                  ^,          Vn        V'       d   V;P
                  ^,          un        V P                  P                  V\        V4      4       R# r:   )r   r1   r'   r3   r<   r2   r   r&   )r   r>   target_is_directoryr  s   &&& r   
symlink_toWritableZipPath.symlink_toK  sQ    D	*"llb04'uc&k2r   r  Nr  )i  rw   )rj   rk   rl   rm   r   r   r  r   r   r   r   r   r   r   r  r  r!  rp   rq   rr   s   @r   r
  r
  #  sK      *IF!0K
1
SA2*3 3r   r
  )r   r   r   r  r3   r   r   r   r   r   r/   r   pathlib_abcr   r   r	   pathlib.typesr   ru   r   r   r   r   r
  rx   r   r   <module>r%     s     	    2 2 
BBDDA6 A6H , +, S+( S+lF F2<Nm <N~-3m -3r   