
    Ki                     >    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             \/var/www/html/dynamic-report/venv/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S[        4S jn[        U[        5      (       d  [        U5      nUR                  S5      nU" U5      n[	        U5      nU R                  5         0 n	XR                  ;   a3  U R                  U   S   S:X  a  U R                  U   X'   U(       a  U	$ U/$ U R                  R                  5        H|  u  p[	        U" U
5      =n5      U:  d   [        S [        X|5       5       5      (       a  M>  US   S	:X  a!  U(       a  X;  a  XU
R                  S5      '   Mh  X;  d  Mo  U(       a  UOS X'   M~     U(       a=  U	R                  5        VVs0 s H   u  pUR                  S5      X(-   :  d  M  X_M"     n	nnU(       a  U	$ [        U	5      $ s  snnf )
N   zmaxdepth must be at least 1_pathc           	      j    [        [        S U R                  SS5      R                  S5      5      5      $ )N\r.   )listfilterreplacesplit)rk   s    r*   to_parts$ZipFileSystem.find.<locals>.to_parts   s*    tU]]4%=%C%CC%HIJJr,   r.   rA   rB   c              3   .   #    U  H  u  pX:g  v   M     g 7frV    ).0r   r   s      r*   	<genexpr>%ZipFileSystem.find.<locals>.<genexpr>   s      J#>41#>s   r>   )r   r   r   r0   lenrS   r#   itemsanyr   ra   countsorted)r$   r2   maxdepthwithdirsdetailr'   rr   
path_parts
path_depthresult	file_path	file_info
file_partskvs                  r*   findZipFileSystem.find   s   HqL:;;	KC 	K $$$t9D {{3d^
_
 >>!dnnT&:6&Bf&L>>$/FL#6/$/$(NN$8$8$: I)!44:5
Bc J#&z#>J G G  K/	 73<9??3/0&17IT! %; !'!/1773<(BW3W    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m4- m4r,   