
    7Th                     >    S SK r S SKrS SKrS SKJr   " S S\5      rg)    N)AbstractArchiveFileSystemc                      ^  \ rS rSrSrSrSrSrSSSS\R                  SS4U 4S	 jjr
\U 4S
 j5       rS rS rS rS r    SS jrSS jrSrU =r$ )ZipFileSystem   zRead/Write contents of ZIP archive as a file-system

Keeps file object open while instance lives.

This class is pickleable, but not necessarily thread-safe
 zipFrNTc                   > [         T
U ]  " U 40 UD6  U[        S5      ;  a  [        SU S35      eX l        [        U[        [        R                  45      (       a0  US:X  a  Sn	OUS-   n	[        R                  " U4XS.U=(       d    0 D6nX`l        Xl        UR                  5       U l        [        R                   " U R                  UUUUS9U l        S	U l        g	)
a+  
Parameters
----------
fo: str or file-like
    Contains ZIP, and must exist. If a str, will fetch file using
    :meth:`~fsspec.open_files`, which must return one file exactly.
mode: str
    Accept: "r", "w", "a"
target_protocol: str (optional)
    If ``fo`` is a string, this value can be used to override the
    FS protocol inferred from a URL
target_options: dict (optional)
    Kwargs passed when instantiating the target FS, if ``fo`` is
    a string.
compression, allowZip64, compresslevel: passed to ZipFile
    Only relevant when creating a ZIP
rwazmode 'z' no understoodazr+bb)modeprotocol)r   compression
allowZip64compresslevelN)super__init__set
ValueErrorr   
isinstancestrosPathLikefsspecopenforce_zip_64of	__enter__fozipfileZipFiler   	dir_cache)selfr    r   target_protocoltarget_optionsr   r   r   kwargsm	__class__s             R/var/www/auris/envauris/lib/python3.13/site-packages/fsspec/implementations/zip.pyr   ZipFileSystem.__init__   s    8 	((s5z!vdV?;<<	b3,--s{3J9G9M2B ',,.??GG#!'
     c                 @   > [         TU ]  U5      R                  S5      $ )N/)r   _strip_protocollstrip)clspathr)   s     r*   r/   ZipFileSystem._strip_protocolH   s      w&t,33C88r,   c                 L    [        U S5      (       a  U R                  5         U ?g g )Nr   )hasattrcloser   r$   s    r*   __del__ZipFileSystem.__del__M   s"    4JJL  r,   c                 8    U R                   R                  5         g)z;Commits any write changes to the file. Done on ``del`` too.N)r   r6   r7   s    r*   r6   ZipFileSystem.closeR   s    r,   c           
         U R                   b  U R                  [        S5      ;   Ga  U R                  R	                  5       nU R                  U R                  R                  5       5       Vs0 s H(  nUR                  S5      UR                  S5      SSS._M*     snU l         U H  n[        R                  R                   Vs0 s H  oD[        X4S 5      _M     nnUR                  UR                  R                  S5      UR                  UR                  5       (       a  SOSS.5        XPR                   US   '   M     g g s  snf s  snf )Nwar.   r   	directory)namesizetypefiler?   )r#   r   r   r   infolist_all_dirnamesnamelistrstripr!   ZipInfo	__slots__getattrupdatefilename	file_sizeis_dir)r$   filesdirnamezsfs         r*   	_get_dirsZipFileSystem._get_dirsV   s$   >>!TYY#d)%; HH%%'E  $11$((2C2C2EF  GG s##NN3/'& 
  GDN 5<__5N5NO5Nd++5NO !

 1 1# 6 !01

 -.qy)  &< Ps   -/EEc                 >    U R                   R                  " X40 UD6  g N)r   writestr)r$   r2   valuer'   s       r*   	pipe_fileZipFileSystem.pipe_filen   s    $00r,   c                    U R                  U5      nSU;   aE  U R                  [        S5      ;   a,  U R                  U5      (       a  [	        S5      e[        U5      eSU R                  ;   a  SU;   a  [	        S5      eU R                  R                  XR                  S5      U R                  S9nSU;   a%  U R                  U5      nUS   Ul        US   Ul        U$ )	Nr	   r=   z7ZipFS can only be open for reading or writing, not bothwr   )force_zip64r@   r?   )r/   r   r   existsOSErrorFileNotFoundErrorr   r   stripr   infor@   r?   )	r$   r2   r   
block_size
autocommitcache_optionsr'   outrb   s	            r*   _openZipFileSystem._openr   s     ##D)$;499D	1{{4  WXX#D))$))tSTThhmmD**S/t?P?PmQ$;99T?DF|CHF|CH
r,   c                   ^ Ub  US:  a  [        S5      eUR                  S5      n[        [        S UR	                  S5      5      5      mU4S jnU R                  5         0 nXR                  ;   a3  U R                  U   S   S:X  a  U R                  U   Xq'   U(       a  U$ U/$ U R                  R                  5        HX  u  pUS:X  d  U" U5      (       d  M  U	S   S	:X  a!  U(       a  X;  a  XUR                  S5      '   MD  X;  d  MK  U(       a  U	OS Xx'   MZ     U(       aO  UR                  S5      n
UR                  5        VVs0 s H!  u  pUR                  S5      U
-
  U:  d  M  X_M#     nnnU(       a  U$ [        U5      $ s  snnf )
N   zmaxdepth must be at least 1r.   c                     [        U 5      $ rV   boolrQ   s    r*   <lambda>$ZipFileSystem.find.<locals>.<lambda>   s    47r,   c                 t   > [        S U R                  S5      5      n[        S [        TU5       5       5      $ )Nc                     [        U 5      $ rV   rl   rn   s    r*   ro   >ZipFileSystem.find.<locals>._matching_starts.<locals>.<lambda>   s    $q'r,   r.   c              3   .   #    U  H  u  pX:H  v   M     g 7frV    ).0r   r   s      r*   	<genexpr>?ZipFileSystem.find.<locals>._matching_starts.<locals>.<genexpr>   s     F*E$!qv*Es   )filtersplitallr   )	file_path
file_parts
path_partss     r*   _matching_starts,ZipFileSystem.find.<locals>._matching_starts   s1     19??33GHJF#j**EFFFr,   rA   rB   r   r>   )r   r0   listry   rz   rS   r#   itemsra   countsorted)r$   r2   maxdepthwithdirsdetailr'   r   resultr|   	file_info
path_depthkvr~   s                @r*   findZipFileSystem.find   sm   HqL:;; {{3&!2DJJsODE
	G 	 >>!dnnT&:6&Bf&L>>$/FL#6/$/$(NN$8$8$: IBJ"29"="= K/ .7@ys34&17IT! %; CJ!'!/1773<*3Lx3W    v3VF^3s   F)F)r#   r    r   r   r   r   )rbNTN)NFF)__name__
__module____qualname____firstlineno____doc__root_markerr   cachabler!   
ZIP_STOREDr   classmethodr/   r8   r6   rS   rY   rg   r   __static_attributes____classcell__)r)   s   @r*   r   r      s     KHH &&2h 9 9
.01 .(4 (4r,   r   )r   r!   r   fsspec.archiver   r   ru   r,   r*   <module>r      s     	   4i4- i4r,   