
    gR                     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              N/var/www/openai/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                  |d      |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                  |d      |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                  |d      |rg ngk(  rJ  y )Nr	   FTr   r   detail	recursiver   subfile2	nesteddir
nestedfile   r1   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&L,)AS ,&A FF1aL555.0ug  
 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5.0ug  
 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5.0ug   +L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$   r0   r   r2   r3   r4   r5   r6   )r   r8   r   r9   pytestraisesFileNotFoundErrorr   r   r   r   )r   r   r   r   r   r   r   r   r:   r;   r<   r=   s               r    #test_put_directory_to_new_directoryz4AbstractPutTests.test_put_directory_to_new_directory   se    2
*-udmeT]*K&L,)AS)AS FF1aL)uuV}***]]#45EE&M 6 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 +L 65s   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                  |d      |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                  |d      |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                  |d      |rg n	gk(  rJ   y )Nr	   FTr   r   *r   r2   r3   r4   Tr0   Fr.   **r5   r6   )	r   r   r   r   r   r   r   r9   r8   )r   r   r   r   r   r   r   r   r   r	   r;   r=   globr1   s                 r    #test_put_glob_to_existing_directoryz4AbstractPutTests.test_put_glob_to_existing_directory   sS    2
)FG,EHHUOxx)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5.0ug  
 $'T{T5M#Biz&(D91	Ryy!<===yy!<===xx <===yyl!KLLL99WVX%>???
3
34
 #   uuVEu24B5'  
 vx6'	   yy!<===yy!<===99WV[%ABBB99WVX%>???
3
3 #   uuVEu24B5'  O $C/ *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 )NrE   r$   r   r   rF   r   r2   r3   r4   Tr0   rG   Fr5   r6   )r   r   r   r   r   r   r8   )r   r   r   r   r   r   r   r   r;   r=   rH   r1   s               r    test_put_glob_to_new_directoryz/AbstractPutTests.test_put_glob_to_new_directoryL  s^    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 $C' *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   r6   r0   )r   r   r   findsortedr   rB   )r   pathr1   r7   expectedr   r   r   local_glob_edge_cases_filesr   fs_sanitize_pathr   r   new_dirr;   r=   outputpprefixed_expecteds                      r    test_put_glob_edge_casesz)AbstractPutTests.test_put_glob_edge_cases  s&   $ -%,dE]T5M%J!G\HHV-4)&A'CQAFF:fd+Q)hFWWWV_FLT%LTq$WVXq%ABH " %
 CK%BJQ$WVQ%78( " % &>V,=%>>>>f-) &K%% % s   5CC C%%	C10C1c           	      2   |}|}|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                  |d
      |rg n	gk(  rJ  y )Nr	   file1r
   r   r   rE   r   Tr0   Fr.   )r   r   r   r   r   r   r9   )r   r   r   r   r   r   r   r   r   r	   source_filesr;   r=   s                r    ,test_put_list_of_files_to_existing_directoryz=AbstractPutTests.test_put_list_of_files_to_existing_directory  sD    2
)FG,EHHUOxx vw'vw'vx4
 *L ,&AFF<#99WVW566699WVW566699WVZ8999EEFG,FG,FJ/
    555.0ug  ! *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 )Nr[   r
   r   r   r$   r   r%   )	r   r   r   r   r   r   r   r   r\   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   Tr0   r   r   )r   r   r   ranger   r   r   r   )r   r   r   r   local_fsr   
local_pathra   src_filer   loops              r    test_put_directory_recursivez-AbstractPutTests.test_put_directory_recursive  s   
 U+c6*sx  99V$$$!HDFF3$F/88F###qyyy!899999WVU%;<<<yy!8999xx 6777yy!?@@@  	f% 99V$$$!HDFF39fF588F###99WVV4555yy!7888	 r"   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   Tr0   zsubfile.txtz
subdir.txtzsubdir*)r   r   r   r9   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)	rd   r   strencode	hexdigestappendr   catdecode)r   r   r   r   r    local_10_files_with_hashed_namesr   r   r\   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A3q6==12<<>H
6hZt3D EF$$WVz5F%GH  	\):;rA66"3A"67>>wGL3q6))) r"   N)__name__
__module____qualname__r!   r'   r*   r,   r>   rC   rI   rK   r@   markparametrizer   rY   r]   r_   ri   rl   r|    r"   r    r   r   	   s    )*V@ 5,? Tl3<jTl8@t [[j)k*(	(T,\@*"9H;@*r"   r   )hashlibr   	itertoolsr   r@   fsspec.tests.abstract.commonr   r   r   r"   r    <module>r      s       >F	* F	*r"   