
    "hQ                     D    d dl mZ d dlmZ d dlZd dlmZ  G d d      Zy)    )md5)productN)GLOB_EDGE_CASES_TESTSc                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
ej                  j                  ed	   ed
         d        Zd Zd Zd Zd Zd Zy)AbstractPutTestsc                    |}|}|j                  |       |s|j                   ||d             |j                  |      sJ  ||d      }	 ||d      }
|j                   ||d      |       |j	                  |	      sJ |j                   ||dd      |       |j	                  |
      sJ |j                  |	|
g       |j                  |	      rJ |j                  |
      rJ |j                   ||d      |dz          |j                  |      sJ |j	                  |	      sJ |j                   ||dd      |dz          |j	                  |
      sJ y )Ndummyfile2subfile1subdir/)mkdirtouchisdirputisfilermexists)selffsfs_join	fs_target
local_join local_bulk_operations_scenario_0supports_empty_directoriessourcetargettarget_file2target_subfile1s              V/var/www/html/sandstorm/venv/lib/python3.12/site-packages/fsspec/tests/abstract/put.py#test_put_file_to_existing_directoryz4AbstractPutTests.test_put_file_to_existing_directory
   sQ    2
)HHWVW-.xxvw/!&*5 	z&'*F3yy&&& 	z&(J7@yy))) 	|_-.99\***99_--- 	z&'*FSL9xxyy&&&
z&(J7#Fyy)))    c                     |}|}|j                  |       |j                   ||dd       ||d             |j                  |      sJ |j                   ||d            sJ |j                   ||dd            sJ y )Nr   r   znewdir/newdirr   r   r   r   r   r   r   r   r   r   r   r   s           r    test_put_file_to_new_directoryz/AbstractPutTests.test_put_file_to_new_directory5   s     2

vx4gfi6P	
 xxxx1222yy:>???r"   c                     |}|}|j                  |       |s|j                   ||d             |j                  |      sJ |j                   ||dd       ||d             |j	                   ||d            sJ y )Nr	   r   r   newfile)r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   s	            r    +test_put_file_to_file_in_existing_directoryz<AbstractPutTests.test_put_file_to_file_in_existing_directoryE   sy     2
)HHWVW-.xx
z&(J79STyy3444r"   c                     |}|}|j                  |       |j                   ||dd       ||dd             |j                   ||d            sJ |j                   ||dd            sJ y )Nr   r   r$   r)   r%   r&   s           r    &test_put_file_to_file_in_new_directoryz7AbstractPutTests.test_put_file_to_file_in_new_directory[   st     2

vx4FHi0	
 xx1222yy9=>>>r"   c           	         |}|}|j                  |       |s ||d      }|j                  |       |j                  |      sJ t        ddgddg      D ]  \  }	}
 ||d      }|	r|dz  }|
r|dz   n|}|j	                  ||       |j                  |      |rg ngk(  sJ |j	                  ||d       |	r|j                   ||d            sJ |j                   ||d            sJ |j                   ||d	            sJ |j                   ||d	d
            sJ |j                   ||d            rJ |j                   ||d       ||d       ||d	      gd       n|j                   ||d            sJ |j                   ||dd            sJ |j                   ||dd            sJ |j                   ||dd	            sJ |j                   ||dd	d
            sJ |j                   ||d      d       |j                  |      |rg ngk(  sJ |j	                  ||dd       |	r|j                   ||d            sJ |j                   ||d            sJ |j                   ||d	            rJ |j                   ||d            rJ |j                   ||d       ||d      gd       n|j                   ||d            sJ |j                   ||dd            sJ |j                   ||dd            sJ |j                   ||dd	            rJ |j                   ||d      d       |j                  |      |rg ngk(  rJ  y )Nr	   FTr   r   	recursiver   subfile2	nesteddir
nestedfile   r/   maxdepth)	r   r   r   zipr   lsr   r   r   )r   r   r   r   r   r   r   r   r	   source_slashtarget_slashsts                r    (test_put_directory_to_existing_directoryz9AbstractPutTests.test_put_directory_to_existing_directoryk   s    2
)FG,EHHUOxx*-udmeT]*K ;	T&L,)AS ,&A FF1aL55=+ERE7SSS FF1a4F(yy!<===yy!<===xx <===yyl!KLLL99WVX%>???
3
34
 #   xx 9:::yy:!FGGGyy:!FGGGxx+ FGGGyy;!UVVVgfh/4@55=+ERE7SSS FF1a4!F4yy!<===yy!<===99WV[%ABBB99WVX%>???
3
3 #   xx 9:::yy:!FGGGyy:!FGGG99WVX{%KLLLgfh/4@55=+ERE7SSSw;	Tr"   c           	         |}|}|j                  |       t        ddgddg      D ]:  \  }}	 ||d      }
|r|
dz  }
 ||d      }|	r|dz  }|j                  |
|       |r|j                  |      g k(  s5J t	        j
                  t              5  |j                  |       d d d        |j                  |
|d       |j                   ||d            sJ |j                   ||dd            sJ |j                   ||dd            sJ |j                   ||dd	            sJ |j                   ||dd	d
            sJ |j                   ||d            rJ |j                   ||d      d       |j                   ||d            rJ |j                  |
|dd       |j                   ||d            sJ |j                   ||dd            sJ |j                   ||dd            sJ |j                   ||dd	            rJ |j                   ||d            rJ |j                   ||d      d       |j                   ||d            s;J  y # 1 sw Y   xY w)NFTr   r   r$   r.   r   r0   r1   r2   r3   r4   )r   r6   r   r7   pytestraisesFileNotFoundErrorr   r   r   r   )r   r   r   r   r   r   r   r   r8   r9   r:   r;   s               r    #test_put_directory_to_new_directoryz4AbstractPutTests.test_put_directory_to_new_directory   sp    2
*-udmeT]*K %	<&L,)AS)AS FF1aL)uuV}***]]#45 "EE&M" FF1a4F(88GFH566699WVXzBCCC99WVXzBCCC88GFHkBCCC99WVX{LQRRRyy!:;;;EE'&(+tE<yy!:;;; FF1a4!F488GFH566699WVXzBCCC99WVXzBCCCyy;!GHHHyy!:;;;EE'&(+tE<yy!:;;;K%	<" "s   I%%I/	c           
         |}|}|j                  |       |s ||d      }	|j                  |	       |j                  |      sJ dD ]  }
|
r|dz   n|}|j                   ||dd      |       |j	                   ||d            sJ |j	                   ||d            sJ |j                   ||d            rJ |j                   ||dd	            rJ |j                   ||d            rJ |j                   ||d       ||d      gd
       |j                  |      |rg n	gk(  sJ t        ddgd
dg      D ]  \  }}|j                   ||d|      ||       |j	                   ||d            sJ |j	                   ||d            sJ |j                   ||d            sJ |j	                   ||dd	            sJ |j                   ||d            rJ |j                   ||d       ||d       ||d      gd
       |j                  |      |rg n	gk(  sJ |j                   ||d|      ||d       |j	                   ||d            sJ |j	                   ||d            sJ |j                   ||d            rJ |j                   ||d            rJ |j                   ||d       ||d      gd
       |j                  |      |rg n	gk(  rJ   y )Nr	   FTr   r   *r   r0   r1   r2   Tr.   **Fr3   r4   )	r   r   r   r   r   r   r   r7   r6   )r   r   r   r   r   r   r   r   r   r	   r9   r;   globr/   s                 r    #test_put_glob_to_existing_directoryz4AbstractPutTests.test_put_glob_to_existing_directory   sA    2
)FG,EHHUOxx) :	XL ,&A FF:fh4a899WVZ899999WVZ8999xx <===yyl!KLLLyy!:;;;EEFJ/FJ/    55=+ERE7SSS $'T{T5M#B %Xiz&(D91	Ryy!<===yy!<===xx <===yyl!KLLL99WVX%>???
3
34
 #   uuV}/IPUwWWW vx6'	   yy!<===yy!<===99WV[%ABBB99WVX%>???
3
3 #   uuV}/IPUwWWWK%X+:	Xr"   c           
         |}|}|j                  |       dD ]4  } ||d      }	|r|	dz  }	|j                   ||dd      |	       |j                   ||d            sJ |j                   ||dd            sJ |j                   ||dd            sJ |j	                   ||dd            rJ |j	                   ||ddd	            rJ |j	                   ||d            rJ |j	                   ||dd            rJ |j                   ||d      d
       |j	                   ||d            rJ t        ddgd
dg      D ]  \  }
}|j                   ||d|
      |	|       |j                   ||d            sJ |j                   ||dd            sJ |j                   ||dd            sJ |j                   ||dd            sJ |j                   ||ddd	            sJ |j	                   ||d            rJ |j	                   ||dd            rJ |j                   ||d      d
       |j	                   ||d            rJ |j                   ||d|
      |	|d       |j                   ||d            sJ |j                   ||dd            sJ |j                   ||dd            sJ |j	                   ||dd            rJ |j	                   ||d            rJ |j	                   ||dd            rJ |j                   ||d      d
       |j	                   ||d            sJ  7 y )NrC   r$   r   r   rD   r   r0   r1   r2   Tr.   rE   Fr3   r4   )r   r   r   r   r   r   r6   )r   r   r   r   r   r   r   r   r9   r;   rF   r/   s               r    test_put_glob_to_new_directoryz/AbstractPutTests.test_put_glob_to_new_directory@  sk    2
) /	@L)AS FF:fh4a888GFH566699WVXzBCCC99WVXzBCCCyy;!GHHHyy;!UVVVyy!:;;;yy8!DEEEEE'&(+tE<yy!:;;; $'T{T5M#B @iz&(D91	Rxx 9:::yy:!FGGGyy:!FGGGxx+ FGGGyy;!UVVV99WVX%>???99WVXx%HIIIgfh/4@99WVX%>??? vx6'	   xx 9:::yy:!FGGGyy:!FGGG99WVX{%KLLL99WVX%>???99WVXx%HIIIgfh/4@99WVX%>???9@'/	@r"   argnames	argvaluesc                    |}|}t        ddgddg      D ]  \  }}|j                  |       |r	 ||d      n|}|r|dz   n|}|j                   |	||      |||       |j                  |      }|r|D cg c]  } |
 ||d|             }}n|D cg c]  } |
 |||             }}t	        |      t	        |      k(  sJ 	 |j                  |d        y c c}w c c}w # t        $ r Y w xY w)NTFr$   r   r4   r.   )r   r   r   findsortedr   r@   )r   pathr/   r5   expectedr   r   r   local_glob_edge_cases_filesr   fs_sanitize_pathr   r   new_dirr9   r;   outputpprefixed_expecteds                      r    test_put_glob_edge_casesz)AbstractPutTests.test_put_glob_edge_casesz  s(   $ -%,dE]T5M%J 	!G\HHV-4)&A'CQAFF:fd+Q)hFWWWV_FLT%GH$WVXq%AB%! %
 CK%=>$WVQ%78%! % &>V,=%>>>>f-)	%% % s   5CC C%%	C10C1c           	      .   |}|}|j                  |       |s ||d      }	|j                  |	       |j                  |      sJ  ||d       ||d       ||dd      g}
dD ]  }|r|dz   n|}|j                  |
|       |j	                   ||d            sJ |j	                   ||d            sJ |j	                   ||d            sJ |j                   ||d       ||d       ||d      gd	       |j                  |      |rg n	gk(  rJ  y )
Nr	   file1r
   r   r   rC   r   Tr.   )r   r   r   r   r   r   r7   )r   r   r   r   r   r   r   r   r   r	   source_filesr9   r;   s                r    ,test_put_list_of_files_to_existing_directoryz=AbstractPutTests.test_put_list_of_files_to_existing_directory  s@    2
)FG,EHHUOxx vw'vw'vx4
 * 	TL ,&AFF<#99WVW566699WVW566699WVZ8999EEFG,FG,FJ/
    55=+ERE7SSS!	Tr"   c                 r   |}|}|j                  |        ||d       ||d       ||dd      g}|j                  | ||d      dz          |j                   ||d            sJ |j                   ||dd            sJ |j                   ||dd            sJ |j                   ||dd            sJ y )NrY   r
   r   r   r$   r   r%   )	r   r   r   r   r   r   r   r   rZ   s	            r    'test_put_list_of_files_to_new_directoryz8AbstractPutTests.test_put_list_of_files_to_new_directory  s     2
 vw'vw'vx4
 	|WVX6<=xx1222yy7;<<<yy7;<<<yy:>???r"   c                 >    ||d      } ||d      }|j                  |       |j                  |       |}	|j                  |	      rJ t        d      D ]  }
|j	                  ||	d       |j                  |	      sJ |
dk(  r5|j                   ||	d            sJ |j                   ||	d            sbJ |j                   ||	d            sJ |j                   ||	d            sJ |j                   ||	dd            rJ  |j                  |	d       |j                  |	      rJ t        d      D ]`  }
|j	                  |dz   |	d       |j                  |	      sJ |j                   ||	d            sJ |j                   ||	d            s`J  y )Nsrcfile   Tr.   r   r   )r   r   r   ranger   r   r   r   )r   r   r   r   local_fsr   
local_pathr_   src_filer   loops              r    test_put_directory_recursivez-AbstractPutTests.test_put_directory_recursive  s   
 U+c6*sx  99V$$$!H 
	ADFF3$F/88F###qyyy!899999WVU%;<<<yy!8999xx 6777yy!?@@@
	A 	f% 99V$$$!H 	9DFF39fF588F###99WVV4555yy!7888		9r"   c                    |}|}|j                   ||d      |d       |j                   ||d            sJ |j                   ||d            rJ |j                   ||d      g       |r|j                  |      g k(  sJ |j	                  |      rJ |j                   ||d      |d       |j                   ||d            sJ |j                   ||dd            sJ |j                   ||d            sJ y )Nr   Tr.   zsubfile.txtz
subdir.txtzsubdir*)r   r   r   r7   r   r   )	r   r   r   r   r   (local_dir_and_file_with_same_name_prefixr   r   r   s	            r    6test_put_directory_without_files_with_same_name_prefixzGAbstractPutTests.test_put_directory_without_files_with_same_name_prefix  s    : 	z&(+Y$GyyM:;;;99WY=>>>
wv}-./%55=B&&&yy((( 	z&),i4Hxx	84555yyHmDEEEyyL9:::r"   c                    |}|}g }g }	t        d      D ]i  }
t        t        |
      j                  d            j	                         }|j                   ||| d             |	j                   ||| d             k |j                  ||	       t        d      D ]5  }
|j                  |	|
         j                  d      }|t        |
      k(  r5J  y )N
   zutf-8z.txt)lpathrpath)	rb   r   strencode	hexdigestappendr   catdecode)r   r   r   r   r    local_10_files_with_hashed_namesr   r   rZ   destination_filesihashed_ifile_contents                r    -test_copy_with_source_and_destination_as_listz>AbstractPutTests.test_copy_with_source_and_destination_as_list-  s     2 r 	IA3q6==12<<>H
6hZt3D EF$$WVz5F%GH	I 	\):;r 	*A66"3A"67>>wGL3q6)))	*r"   N)__name__
__module____qualname__r!   r'   r*   r,   r<   rA   rG   rI   r>   markparametrizer   rW   r[   r]   rg   rj   rz    r"   r    r   r   	   s    )*V@ 5,? NT`3<jNX`8@t [[j)k*(	(T*TX@*"9H;@*r"   r   )hashlibr   	itertoolsr   r>   fsspec.tests.abstract.commonr   r   r   r"   r    <module>r      s       >x* x*r"   