
    "h+                     2    d dl mZ d dlmZ  G d de      Zy)   )
filesystem)AsyncFileSystemc                       e Zd ZdZdZ	 	 	 	 	 d@ fd	Zd Zd Zed        Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d  Z#d! Z$d" Z%d# Z&d$ Z'd% Z(d& Z)d' Z*dAd(Z+dAd)Z,d* Z-d+ Z.d, Z/d- Z0d. Z1d/ Z2d0 Z3d1 Z4d2 Z5d3 Z6d4 Z7d5 Z8d6 Z9d7 Z:d8 Z;d9 Z<d: Z=d; Z>d< Z?d= Z@d> ZAd? ZB xZCS )BDirFileSystemzDirectory prefix filesystem

    The DirFileSystem is a filesystem-wrapper. It assumes every path it is dealing with
    is relative to the `path`. After performing the necessary paths operation it
    delegates everything to the wrapped filesystem.
    dirc                 b   t        |   di | |t        dd|i|xs i }|du|duz  du rt        d      |xs |}| j                  r|j
                  st        d      |j
                  r$| j                  |j                  k7  rt        d      |j                  |      | _        || _        y)aS  
        Parameters
        ----------
        path: str
            Path to the directory.
        fs: AbstractFileSystem
            An instantiated filesystem to wrap.
        target_protocol, target_options:
            if fs is none, construct it from these
        fo: str
            Alternate for path; do not provide both
        NprotocolFzProvide path or fo, not bothz(can't use asynchronous with non-async fsz7both dirfs and fs should be in the same sync/async mode )	super__init__r   
ValueErrorasynchronous
async_impl_strip_protocolpathfs)selfr   r   fotarget_protocoltarget_optionsstorage_options	__class__s          Y/var/www/html/sandstorm/venv/lib/python3.12/site-packages/fsspec/implementations/dirfs.pyr   zDirFileSystem.__init__   s    * 	+?+:O_O9M2OB40E9;<<zrR]]GHH==T.."//AVWW&&t,	    c                 "   t        |t              r\| j                  s|S |s| j                  S | j                  j                  j                  | j                  | j                  |      f      S |D cg c]  }| j                  |       c}S c c}w N)
isinstancestrr   r   sepjoinr   _join)r   r   _paths      r   r!   zDirFileSystem._join4   so    dC 99yy 77;;##TYY0D0DT0J$KLL/34e

5!444s   1Bc                 .   t        |t              rb| j                  s|S || j                  k(  ry| j                  | j                  j                  z   }|j                  |      sJ |t        |      d  S |D cg c]  }| j                  |       c}S c c}w )N )r   r   r   r   r   
startswithlen_relpath)r   r   prefixr"   s       r   r'   zDirFileSystem._relpath=   s}    dC 99tyy YY,F??6***F&&267e$777s   7Bc                 .    | j                   j                  S r   )r   r   r   s    r   r   zDirFileSystem.sepJ   s    ww{{r   c                 V   K    | j                   j                  |i | d {   S 7 wr   )r   set_session)r   argskwargss      r   r,   zDirFileSystem.set_sessionN   s(     (TWW(($9&9999s    )')c                 v   K    | j                   j                  | j                  |      fi | d {   S 7 wr   )r   _rm_filer!   r   r   r.   s      r   r0   zDirFileSystem._rm_fileQ   s1     %TWW%%djj&6A&AAAA   0979c                 Z     | j                   j                  | j                  |      fi |S r   )r   rm_filer!   r1   s      r   r4   zDirFileSystem.rm_fileT   s%    twwtzz$/:6::r   c                 |   K    | j                   j                  | j                  |      g|i | d {   S 7 wr   )r   _rmr!   r   r   r-   r.   s       r   r6   zDirFileSystem._rmW   s4      TWW[[D!1CDCFCCCC   3<:<c                 `     | j                   j                  | j                  |      g|i |S r   )r   rmr!   r7   s       r   r:   zDirFileSystem.rmZ   s*    twwzz$**T*<T<V<<r   c                    K    | j                   j                  | j                  |      | j                  |      fi | d {   S 7 wr   )r   _cp_filer!   r   path1path2r.   s       r   r<   zDirFileSystem._cp_file]   s<     %TWW%%djj&7E9JUfUUUUs   A A	AA	c                 z     | j                   j                  | j                  |      | j                  |      fi |S r   )r   cp_filer!   r=   s       r   rA   zDirFileSystem.cp_file`   s0    twwtzz%0$**U2CNvNNr   c                    K    | j                   j                  | j                  |      | j                  |      g|i | d {   S 7 wr   )r   _copyr!   r   r>   r?   r-   r.   s        r   rC   zDirFileSystem._copyc   sU      #TWW]]JJuJJu
 
 	
 
 	
 
s   AAA
Ac                      | j                   j                  | j                  |      | j                  |      g|i |S r   )r   copyr!   rD   s        r   rF   zDirFileSystem.copyq   sE    tww||JJuJJu
 
 	
 	
r   c                 |   K    | j                   j                  | j                  |      g|i | d {   S 7 wr   )r   _piper!   r7   s       r   rH   zDirFileSystem._pipey   s4     "TWW]]4::d#3EdEfEEEEr8   c                 `     | j                   j                  | j                  |      g|i |S r   )r   piper!   r7   s       r   rJ   zDirFileSystem.pipe|   *    tww||DJJt,>t>v>>r   c                 |   K    | j                   j                  | j                  |      g|i | d {   S 7 wr   )r   	_cat_filer!   r7   s       r   rM   zDirFileSystem._cat_file   6     &TWW&&tzz$'7I$I&IIIIr8   c                 `     | j                   j                  | j                  |      g|i |S r   )r   cat_filer!   r7   s       r   rP   zDirFileSystem.cat_file   ,    tww

4 0B4B6BBr   c                   K    | j                   j                  | j                  |      g|i | d {   }t        |t              r3|j                         D ci c]  \  }}| j                  |      | c}}S |S 7 Ic c}}w wr   )r   _catr!   r   dictitemsr'   r   r   r-   r.   retkeyvalues          r   rS   zDirFileSystem._cat   s      DGGLLJJt

 
 
 c4 @C		L*#uDMM#&-LL

 Ms!   3BA?'BB9BBc                      | j                   j                  | j                  |      g|i |}t        |t              r3|j                         D ci c]  \  }}| j                  |      | c}}S |S c c}}w r   )r   catr!   r   rT   rU   r'   rV   s          r   r[   zDirFileSystem.cat   st    dggkkJJt

 
 c4 @C		L*#uDMM#&-LL
 Ms   A5c                 x   K    | j                   j                  || j                  |      fi | d {   S 7 wr   )r   	_put_filer!   r   lpathrpathr.   s       r   r]   zDirFileSystem._put_file   s3     &TWW&&udjj.?J6JJJJ   1:8:c                 \     | j                   j                  || j                  |      fi |S r   )r   put_filer!   r^   s       r   rc   zDirFileSystem.put_file   s)    twwtzz%'8CFCCr   c                 ~   K    | j                   j                  || j                  |      g|i | d {   S 7 wr   )r   _putr!   r   r_   r`   r-   r.   s        r   re   zDirFileSystem._put   sL      "TWW\\JJu
 
 	
 
 	
 
s   4=;=c                 b     | j                   j                  || j                  |      g|i |S r   )r   putr!   rf   s        r   rh   zDirFileSystem.put   s<    tww{{JJu
 
 	
 	
r   c                 x   K    | j                   j                  | j                  |      |fi | d {   S 7 wr   )r   	_get_filer!   r   r`   r_   r.   s       r   rj   zDirFileSystem._get_file   s3     &TWW&&tzz%'8%J6JJJJra   c                 \     | j                   j                  | j                  |      |fi |S r   )r   get_filer!   rk   s       r   rm   zDirFileSystem.get_file   s)    tww

5 15CFCCr   c                 |   K    | j                   j                  | j                  |      g|i | d {   S 7 wr   )r   _getr!   r   r`   r-   r.   s       r   ro   zDirFileSystem._get   s4     !TWW\\$**U"3EdEfEEEEr8   c                 `     | j                   j                  | j                  |      g|i |S r   )r   getr!   rp   s       r   rr   zDirFileSystem.get   s*    tww{{4::e,>t>v>>r   c                 r   K   | j                   j                  | j                  |             d {   S 7 wr   )r   _isfiler!   r   r   s     r   rt   zDirFileSystem._isfile   (     WW__TZZ%56666   .757c                 V    | j                   j                  | j                  |            S r   )r   isfiler!   ru   s     r   ry   zDirFileSystem.isfile       ww~~djj.//r   c                 r   K   | j                   j                  | j                  |             d {   S 7 wr   )r   _isdirr!   ru   s     r   r|   zDirFileSystem._isdir   s(     WW^^DJJt$45555rw   c                 V    | j                   j                  | j                  |            S r   )r   isdirr!   ru   s     r   r~   zDirFileSystem.isdir       ww}}TZZ-..r   c                 r   K   | j                   j                  | j                  |             d {   S 7 wr   )r   _sizer!   ru   s     r   r   zDirFileSystem._size   s(     WW]]4::d#34444rw   c                 V    | j                   j                  | j                  |            S r   )r   sizer!   ru   s     r   r   zDirFileSystem.size   s    ww||DJJt,--r   c                 r   K   | j                   j                  | j                  |             d {   S 7 wr   )r   _existsr!   ru   s     r   r   zDirFileSystem._exists   rv   rw   c                 V    | j                   j                  | j                  |            S r   )r   existsr!   ru   s     r   r   zDirFileSystem.exists   rz   r   c                 v   K    | j                   j                  | j                  |      fi | d {   S 7 wr   )r   _infor!   r1   s      r   r   zDirFileSystem._info   s/     "TWW]]4::d#3>v>>>>r2   c                 Z     | j                   j                  | j                  |      fi |S r   )r   infor!   r1   s      r   r   zDirFileSystem.info   s%    tww||DJJt,777r   c                 B  K    | j                   j                  | j                  |      fd|i| d {   j                         }|rCg }|D ]:  }|j                         }| j	                  |d         |d<   |j                  |       < |S | j	                  |      S 7 hwNdetailname)r   _lsr!   rF   r'   appendr   r   r   r.   rW   outentrys          r   r   zDirFileSystem._ls   s      TWW[[D!1K&KFKKQQSC "

 $eFm <f

5!" J}}S!! Ls   2BBA)Bc                 &    | j                   j                  | j                  |      fd|i|j                         }|rCg }|D ]:  }|j                         }| j	                  |d         |d<   |j                  |       < |S | j	                  |      S r   )r   lsr!   rF   r'   r   r   s          r   r   zDirFileSystem.ls   s    dggjjD)C&CFCHHJC "

 $eFm <f

5!" J}}S!!r   c                   K    | j                   j                  | j                  |      g|i |2 3 d {   \  }}}| j                  |      ||f %7  6 y wr   )r   _walkr!   r'   r   r   r-   r.   rootdirsfiless          r   r   zDirFileSystem._walk   s^     '4tww}}TZZ5E'W'WPV'W 	3 	3#$e--%tU22	3'Ws%   0AAAAAAAc              /      K    | j                   j                  | j                  |      g|i |D ]  \  }}}| j                  |      ||f  y wr   )r   walkr!   r'   r   s          r   r   zDirFileSystem.walk   sT     !-djj.>!P!P!P 	3D$--%tU22	3s   AAc                 2  K   |j                  dd      } | j                  j                  | j                  |      fi | d {   }|r3|j	                         D ci c]  \  }}| j                  |      | c}}S | j                  |      S 7 Jc c}}w wNr   F)rr   r   _globr!   rU   r'   r   r   r.   r   rW   r   s         r   r   zDirFileSystem._glob  s~     He,!DGGMM$**T"2=f==@C		L*$DMM$'-LL}}S!! >Ls$   ABBBB:BBc                    |j                  dd      } | j                  j                  | j                  |      fi |}|r3|j	                         D ci c]  \  }}| j                  |      | c}}S | j                  |      S c c}}w r   )rr   r   globr!   rU   r'   r   s         r   r   zDirFileSystem.glob
  su    He,dggll4::d+6v6@C		L*$DMM$'-LL}}S!! Ms   Bc                   K   |j                  dd      } | j                  j                  | j                  |      g|i | d {   }|r|S |j	                         D ci c]  \  }}| j                  |      | c}}S 7 ;c c}}w wNtotalT)rr   r   _dur!   rU   r'   r   r   r-   r.   r   rW   r   s          r   r   zDirFileSystem._du  s}     

7D)DGGKK

4 0B4B6BBJ<?IIKHjdDd#T)HH	 C Is$   ABBB#B?BBc                     |j                  dd      } | j                  j                  | j                  |      g|i |}|r|S |j	                         D ci c]  \  }}| j                  |      | c}}S c c}}w r   )rr   r   dur!   rU   r'   r   s          r   r   zDirFileSystem.du  sm    

7D)dggjjD);D;F;J<?IIKHjdDd#T)HHHs   A9c                 8  K   |j                  dd      } | j                  j                  | j                  |      g|i | d {   }|r3|j	                         D ci c]  \  }}| j                  |      | c}}S | j                  |      S 7 Jc c}}w wr   )rr   r   _findr!   rU   r'   r   r   r-   r.   r   rW   r   s          r   r   zDirFileSystem._find!  s     He,!DGGMM$**T"2DTDVDD@C		L*$DMM$'-LL}}S!! ELs$   ABBB!B=BBc                    |j                  dd      } | j                  j                  | j                  |      g|i |}|r3|j	                         D ci c]  \  }}| j                  |      | c}}S | j                  |      S c c}}w r   )rr   r   findr!   rU   r'   r   s          r   r   zDirFileSystem.find(  sz    He,dggll4::d+=d=f=@C		L*$DMM$'-LL}}S!! Ms   Bc                    K   | j                   | j                  j                  | j                  |      g|i | d {         S 7 wr   )r'   r   _expand_pathr!   r7   s       r   r   zDirFileSystem._expand_path/  sD     }}&$''&&tzz$'7I$I&II
 	
Is   >A A		Ac                 ~    | j                   | j                  j                  | j                  |      g|i |      S r   )r'   r   expand_pathr!   r7   s       r   r   zDirFileSystem.expand_path4  s6    }}0TWW00D1ASDSFSTTr   c                 |   K    | j                   j                  | j                  |      g|i | d {   S 7 wr   )r   _mkdirr!   r7   s       r   r   zDirFileSystem._mkdir7  s4     #TWW^^DJJt$4FtFvFFFFr8   c                 `     | j                   j                  | j                  |      g|i |S r   )r   mkdirr!   r7   s       r   r   zDirFileSystem.mkdir:  s*    tww}}TZZ-????r   c                 |   K    | j                   j                  | j                  |      g|i | d {   S 7 wr   )r   	_makedirsr!   r7   s       r   r   zDirFileSystem._makedirs=  rN   r8   c                 `     | j                   j                  | j                  |      g|i |S r   )r   makedirsr!   r7   s       r   r   zDirFileSystem.makedirs@  rQ   r   c                 V    | j                   j                  | j                  |            S r   )r   rmdirr!   ru   s     r   r   zDirFileSystem.rmdirC  r   r   c                 z     | j                   j                  | j                  |      | j                  |      fi |S r   )r   mv_filer!   r=   s       r   r   zDirFileSystem.mv_fileF  s;    twwJJuJJu
 
 	
r   c                 Z     | j                   j                  | j                  |      fi |S r   )r   touchr!   r1   s      r   r   zDirFileSystem.touchM  s%    tww}}TZZ-888r   c                 V    | j                   j                  | j                  |            S r   )r   createdr!   ru   s     r   r   zDirFileSystem.createdP  s    wwtzz$/00r   c                 V    | j                   j                  | j                  |            S r   )r   modifiedr!   ru   s     r   r   zDirFileSystem.modifiedS  s     ww

4 011r   c                 `     | j                   j                  | j                  |      g|i |S r   )r   signr!   r7   s       r   r   zDirFileSystem.signV  rK   r   c                 h    | j                   j                   d| j                   d| j                   dS )Nz(path='z', fs=))r   __qualname__r   r   r*   s    r   __repr__zDirFileSystem.__repr__Y  s.    ..--.gdii[twwiqQQr   c                 `     | j                   j                  | j                  |      g|i |S r   )r   openr!   r7   s       r   r   zDirFileSystem.open\  s9     tww||JJt

 
 	
r   )NNNNN)T)D__name__
__module__r   __doc__r	   r   r!   r'   propertyr   r,   r0   r4   r6   r:   r<   rA   rC   rF   rH   rJ   rM   rP   rS   r[   r]   rc   re   rh   rj   rm   ro   rr   rt   ry   r|   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__)r   s   @r   r   r      su    H #J5	8  :B;D=VO

F?JC

KD

KDF?706/5.70?8
"
"33""II""

UG@JC/
912?R

r   r   N)r$   r   asynr   r   r
   r   r   <module>r      s     "a
O a
r   