
    7Th4                        S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKJr  SSK	J
r
JrJr  SSKJr  SSKJrJrJrJr  0 r\R*                  " S5      rS	 rSS
 jr      SS jr " S S\
5      r SS jrSS jrS rg)    )annotationsN)Optional   )AsyncFileSystem_run_coros_in_chunkssync_wrapper)DEFAULT_CALLBACK)
filesystemget_filesystem_classsplit_protocol	url_to_fszfsspec.genericc                *    [        U 40 UD6[        U '   g)z4Populate the dict used for method=="generic" lookupsN)r
   _generic_fs)protocolstorage_optionss     F/var/www/auris/envauris/lib/python3.13/site-packages/fsspec/generic.pyset_generic_fsr      s    &xC?CK    c                t   [        U [        [        45      (       a  U S   OU n U=(       d    [        U 5      S   nU=(       d    0 nUS:X  a  [	        U5      $ US:X  a	  [
        U   $ US:X  a  [        U5      nUR                  5       $ US:X  a   [        U 40 UR                  U0 5      D6u  pVU$ [        SU 35      e)zPick instance of backend FSr   defaultgenericcurrentoptionszUnknown FS resolution method: )
isinstancelisttupler   r
   r   r   r   r   get
ValueError)urlmethodr   r   clsfs_s          r   _resolve_fsr$      s    sT5M22#a&C1>#.q1H%+O(##8$$"8,{{}#C!4!4Xr!BC	
5fX>
??r   c           	     6   U=(       d    [        S0 U=(       d    0 D6nUR                  U 5      n UR                  U5      nUR                  U SSS9n	UR                  U 5      (       d  [	        S5      eUR                  USSS9n
U	R                  5        VVs/ s H)  u  pUS   S:X  d  M  UR                  X5      U
;  d  M'  UPM+     nnn[        R                  [        U5       S35        U(       a/  UR                  U Vs/ s H  oR                  X5      PM     snSS9  U	R                  5        VVs0 s H  u  pUS   S:X  d  M  X_M     n	nn[        R                  [        U	5       S	35        U
R                  5        VVs/ s H)  u  pUR                  X5      U	;  d  M  US   S:X  d  M'  UPM+     nnnU	R                  5       R                  5        H  u  nnUR                  X5      nUU
;   as  US
:X  a  UU	U'   M*  US:X  a^  [        U5      (       a  U" U5      OX   nU
U   n[        U5      (       a  U" U5      OUU   nUU:w  a  UU	U'   M{  U	R                  U5        M  M  UU	U'   M     [        R                  [        U	5       S35        U	(       a-  [        U	R                  5       6 u  nnUR                  " UU40 UD6  [        R                  [        U5       S35        U(       a  U(       a  UR!                  U5        U	$ s  snnf s  snf s  snnf s  snnf )a  Sync files between two directory trees

(experimental)

Parameters
----------
source: str
    Root of the directory tree to take files from. This must be a directory, but
    do not include any terminating "/" character
destination: str
    Root path to copy into. The contents of this location should be
    identical to the contents of ``source`` when done. This will be made a
    directory, and the terminal "/" should not be included.
delete_missing: bool
    If there are paths in the destination that don't exist in the
    source and this is True, delete them. Otherwise, leave them alone.
source_field: str | callable
    If ``update_field`` is "different", this is the key in the info
    of source files to consider for difference. Maybe a function of the
    info dict.
dest_field: str | callable
    If ``update_field`` is "different", this is the key in the info
    of destination files to consider for difference. May be a function of
    the info dict.
update_cond: "different"|"always"|"never"
    If "always", every file is copied, regardless of whether it exists in
    the destination. If "never", files that exist in the destination are
    not copied again. If "different" (default), only copy if the info
    fields given by ``source_field`` and ``dest_field`` (usually "size")
    are different. Other comparisons may be added in the future.
inst_kwargs: dict|None
    If ``fs`` is None, use this set of keyword arguments to make a
    GenericFileSystem instance
fs: GenericFileSystem|None
    Instance to use if explicitly given. The instance defines how to
    to make downstream file system instances from paths.

Returns
-------
dict of the copy operations that were performed, {source: destination}
T)withdirsdetailzCan only rsync on a directorytype	directoryz directories to createexist_okfilez files to consider for copyalways	differentz files to copyz files to delete )GenericFileSystem_strip_protocolfindisdirr   itemsreplaceloggerdebuglenmake_many_dirscopycallablepopzipcprm)sourcedestinationdelete_missingsource_field
dest_fieldupdate_condinst_kwargsr"   kwargsallfiles
otherfilesavdirsdirno	to_deletek	otherfileinf1v2inf2source_filestarget_filess                           r   rsyncrW   )   s   h 
	7 7K$527B'F$$[1KwwvTw:H88F899tDAJ NN$$DAV9# 	
()		&(Fj(X 	
$ 	 
 LLCI;456
;?@44\\&.4@4 	 	
 "*!1I!1QvY&5H!1HI
LLCM?"=>? $$&&DA99[)9 	
>?i6>Q 	
&  
 %%'1IIf2	
"h&'+*2<*@*@|Aao	*)1*)=)=z"~2j>4<"+HQK LLO , $HQK# ($ LLCM?.12%((..*:%;"l
lL3F3
LLC	N##345)
iOU AIs6   L)L L L
3LLL"L-Lc                     ^  \ rS rSrSrSrSU 4S jjrS rS rSS jr	S	 r
 SS
 jrS rS rS rSS jrS rS\S4 SS jjrSS jr\" \5      r     S             SS jjrSrU =r$ )r0      aB  Wrapper over all other FS types

<experimental!>

This implementation is a single unified interface to be able to run FS operations
over generic URLs, and dispatch to the specific implementations using the URL
protocol prefix.

Note: instances of this FS are always async, even if you never use it with any async
backend.
r   Nc                >   > Xl         X l        [        TU ]  " S0 UD6  g)am  

Parameters
----------
default_method: str (optional)
    Defines how to configure backend FS instances. Options are:
    - "default": instantiate like FSClass(), with no
      extra arguments; this is the default instance of that FS, and can be
      configured via the config system
    - "generic": takes instances from the `_generic_fs` dict in this module,
      which you must populate before use. Keys are by protocol
    - "options": expects storage_options, a dict mapping protocol to
      kwargs to use when constructing the filesystem
    - "current": takes the most recently instantiated version of each FS
Nr/   )r    st_optssuper__init__)selfdefault_methodr   rG   	__class__s       r   r]   GenericFileSystem.__init__   s      %&"6"r   c                ~    [        XR                  U R                  S9nUR                  UR	                  U5      5      $ Nr   )r$   r    r[   unstrip_protocol_parentr^   pathr"   s      r   rf   GenericFileSystem._parent   s0    {{DLLI""2::d#344r   c                ~    [        XR                  U R                  S9nUR                  UR	                  U5      5      $ rc   )r$   r    r[   re   r1   rg   s      r   r1   !GenericFileSystem._strip_protocol   s2    {{DLLI""2#5#5d#;<<r   c                  #    [        XR                  U R                  S9nUR                  (       a  UR                  " U4X#SS.UD6I S h  vN nOUR
                  " U4X#SS.UD6n0 nUR                  5        H.  u  pU
R                  5       n
UR                  U	5      nXS'   XU'   M0     U(       a  U$ [        U5      $  Ns7f)Nrd   T)maxdepthr&   r'   name)
r$   r    r[   
async_impl_findr2   r4   r:   re   r   )r^   rh   rm   r&   r'   rG   r"   outresultrP   rK   rn   s               r   rp   GenericFileSystem._find   s     {{DLLI=='4KQ C '''4KQC IIKDAA&&q)DfI4L	  
 MF|s   A	CB?A4Cc                
  #    [        XR                  5      nUR                  (       a  UR                  " U40 UD6I S h  vN nOUR                  " U40 UD6nUR                  5       nUR                  US   5      US'   U$  NA7f)Nrn   )r$   r    ro   _infoinfor:   re   )r^   r   rG   r"   rq   s        r   ru   GenericFileSystem._info   sp     kk*==///C''#((Chhj))#f+6F
 0s   =BB ABc                  #    [        XR                  5      nUR                  (       a  UR                  " U4SS0UD6I S h  vN nOUR                  " U4SS0UD6nU Vs/ s H  ofR                  5       PM     nnU H  nUR                  US   5      US'   M     U(       a  U$ U Vs/ s H  ofS   PM	     sn$  Nws  snf s  snf 7f)Nr'   Trn   )r$   r    ro   _lslsr:   re   )r^   r   r'   rG   r"   rq   rN   s          r   ry   GenericFileSystem._ls   s      kk*==s:4:6::C%%3D3F3C!$%Avvx%A++AfI6AfI J'*+s!fIs++ ; & ,s/   ?CB9C B;9/C(C 6C;
Cc                   #    [        XR                  5      nUR                  (       a  UR                  " U40 UD6I S h  vN $ UR                  " U40 UD6$  N7fN)r$   r    ro   	_cat_filecat_file)r^   r   rG   r"   s       r   r~   GenericFileSystem._cat_file   sL     
 kk*==c4V444;;s-f-- 5s   =AA Ac                   #    [        XR                  U R                  S9nUR                  (       a  UR                  " X40 UD6I S h  vN $ UR
                  " X40 UD6$  N7frc   )r$   r    r[   ro   
_pipe_file	pipe_file)r^   rh   valuerG   r"   s        r   r   GenericFileSystem._pipe_file   sR      {{DLLI==t=f===<<6v66 >s   AA"A 	A"c                   #    Un[        U[        5      (       a  U/n[        US   U R                  5      nUR                  (       a  UR
                  " U40 UD6I S h  vN   g UR                  " U40 UD6  g  N7f)Nr   )r   strr$   r    ro   _rmr?   )r^   r   rG   urlsr"   s        r   r   GenericFileSystem._rm  sf     dC  6Da$++.==&&((((EE#   )s   AA9A7A9c                   #    [         R                  SU5        [        XR                  U R                  S9nUR
                  (       a  UR                  XS9I S h  vN   g UR                  XS9  g  N7f)NzMake dir %srd   r*   )r6   r7   r$   r    r[   ro   	_makedirsmakedirs)r^   rh   r+   r"   s       r   r   GenericFileSystem._makedirs  sU     ]D){{DLLI==,,t,777KKK0 8s   AA2A0A2c                     [        X4SU 0UD6  g)zKSync files between two directory trees

See `func:rsync` for more details.
r"   N)rW   )r^   r@   rA   rG   s       r   rW   GenericFileSystem.rsync  s    
 	f5d5f5r   i   c           
       #    [        XR                  5      n[        X R                  5      nXxL a?  UR                  (       a  UR                  " X40 UD6I S h  vN $ UR                  " X40 UD6$ [        Xq/X/USSS9I S h  vN   g  N/ N7f)Nr   raiseon_error)r$   r    ro   _copyr:   copy_file_op)	r^   r   url2	blocksizecallbacktempdirrG   r"   fs2s	            r   _cp_fileGenericFileSystem._cp_file  s      kk*$,9}}XXc:6:::wws3F332uc67APPP ; 	Qs$   ABB)BB
B
Bc                  #    [        US   U R                  5      nUR                  (       a2  U Vs/ s H  oCR                  XBS9PM     nn[	        U5      I S h  vN   g U H  nUR                  XBS9  M     g s  snf  N#7f)Nr   r*   )r$   r    ro   r   r   r   )r^   r   r+   r"   ucoross         r   _make_many_dirs!GenericFileSystem._make_many_dirs1  sl     a$++.==AEFA\\!\7EF&u---A1  G-s   /A?A8	A?A=$A?c           
       #    U(       a  [        S5      e[        U[        5      (       a  U/OUn[        U[        5      (       a  U/OUn[        XR                  5      n	[        X R                  5      n
XL a?  U	R
                  (       a  U	R                  " X40 UD6I S h  vN $ U	R                  " X40 UD6$ [        XXXvUS9I S h  vN   g  N, N7f)NzPlease use fsspec.generic.rsyncr   )	NotImplementedErrorr   r   r$   r    ro   r   r:   r   )r^   path1path2	recursiver   rm   
batch_sizer   rG   r"   r   s              r   r   GenericFileSystem._copy<  s      %&GHH%eS11u%eS11u,%-9}}XXe=f===wwu6v66s7
 	
 	
	 >	
s$   BCC&CCCC)r    r[   )r   N)NFF)T)F)r   Optional[str])FignoreNNN)r   	list[str]r   r   r   boolr   r   rm   Optional[int]r   r   r   r   )__name__
__module____qualname____firstlineno____doc__r   r]   rf   r1   rp   ru   ry   r~   r   r   r   rW   r	   r   r   r   r9   r   __static_attributes____classcell__)r`   s   @r   r0   r0      s    
 H#(5=
( ,&	.
7!16 !!%Q Q&2 "/2N   "&$(!%

 
 	

 
  
 "
 
 
r   r0   c                
  #    SS K nU=(       d    UR                  5       n [        X5       VV	s/ s HO  u  p[        U UUU	[        R
                  R                  U[        R                  " 5       R                  5      5      PMQ     n
nn	[        XSS9I S h  vN n[        R                  " U5        US:X  a  U$ US:X  a!  U H  n[        U[        5      (       d  M  Ue   g g s  sn	nf  NP! [        R                  " U5        f = f7f)Nr   T)r   return_exceptionsreturnr   )tempfilemkdtempr=   _copy_file_oposrh   joinuuiduuid4hexr   shutilrmtreer   	Exception)fs1url1r   r   r   r   r   r   u1u2r   rq   rN   s                r   r   r   \  s      +))+G d/	
 * Wdjjl&6&67 * 	 	
 )D
 
 	g8
	W	A!Y''  
#	

 	gs@   DC( AC C( C&C( <DD C( (D  Dc                \  #    U R                   (       a  U R                  X5      I S h  vN   OU R                  X5        UR                   (       a  UR                  XC5      I S h  vN   OUR	                  XC5        [
        R                  " U5        [        R                  SX5        g  N NE7f)NzCopy %s -> %s; done)	ro   	_get_fileget_file	_put_fileput_filer   unlinkr6   r7   )r   r   r   r   localr   s         r   r   r   z  st     
~~mmD(((T!
~~mmE(((U!IIe
LL&3 	) 	)s"   &B,B(;B,$B*%AB,*B,c                \   #    [         R                  " U 5      (       a
  U I S h  vN $ U $  N7fr}   )inspectiscoroutine)cors    r   maybe_awaitr     s(     3y
 s   !,*,)NN)Fsizer   r.   NN)N   r   )r   )
__future__r   r   loggingr   r   r   typingr   asynr   r   r   	callbacksr	   corer
   r   r   r   r   	getLoggerr6   r   r$   rW   r0   r   r   r   r/   r   r   <module>r      s    "   	    E E ' M M			+	,D
@* ePH
 H
X AI<
4r   