
    çgM                     L    d dl mZ d dlmZ d dlZd dlmZ  G d d          ZdS )    )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                            ed	         ed
                   d             Zd Zd Zd Zd Zd ZdS )AbstractCopyTestsc                 X   |}|}|                     |           |s|                     ||d                     |                    |          sJ  ||d          } ||d          }	|                     ||d          |           |                    |          sJ |                     ||dd          |           |                    |	          sJ |                    ||	g           |                    |          rJ |                    |	          rJ |                     ||d          |dz              |                    |          sJ |                    |          sJ |                     ||dd          |dz              |                    |	          sJ d S )Ndummyfile2subfile1subdir/)mkdirtouchisdircpisfilermexists)
selffsfs_joinfs_bulk_operations_scenario_0	fs_targetsupports_empty_directoriessourcetargettarget_file2target_subfile1s
             V/var/www/html/ai-engine/env/lib/python3.11/site-packages/fsspec/tests/abstract/copy.py$test_copy_file_to_existing_directoryz6AbstractCopyTests.test_copy_file_to_existing_directory
   s    /
) 	/HHWWVW--...xxwvw//!'&*55 	ggfg&&///yy&&&&& 	ggfh
33V<<<yy))))) 	|_-...99\*****99_----- 	ggfg&&555xxyy&&&&&
ggfh
33Vc\BBByy)))))))    c                 B   |}|}|                     |           |                     ||dd           ||d                     |                    |          sJ |                     ||d                    sJ |                     ||dd                    sJ d S )Nr   r   znewdir/newdirr   r   r   r   r   r   r   r   r   r   r   s          r   test_copy_file_to_new_directoryz1AbstractCopyTests.test_copy_file_to_new_directory4   s     /

GFHj1177693M3M	
 	
 	
 xxxx1122222yy:>>???????r!   c                 @   |}|}|                     |           |s|                     ||d                     |                    |          sJ |                     ||dd           ||d                     |                     ||d                    sJ d S )Nr	   r   r   newfile)r   r   r   r   r   )r   r   r   r   r   r   r   r   s           r   ,test_copy_file_to_file_in_existing_directoryz>AbstractCopyTests.test_copy_file_to_file_in_existing_directoryD   s     /
) 	/HHWWVW--...xx
ggfh
33WWVY5O5OPPPyy334444444r!   c                    |}|}|                     |           |                     ||dd           ||dd                     |                     ||d                    sJ |                     ||dd                    sJ d S )Nr   r   r#   r(   r$   r%   s          r   'test_copy_file_to_file_in_new_directoryz9AbstractCopyTests.test_copy_file_to_file_in_new_directoryY   s     /

GFHj117768Y3W3W	
 	
 	
 xx1122222yy9==>>>>>>>r!   c           	         |}|}|                     |           |s! ||d          }|                    |           |                    |          sJ t          ddgddg          D ]\  }	}
 ||d          }|	r|dz  }|
r|dz   n|}|                    ||           |                    |d          |rg n|gk    sJ |                    ||d           |	r|                     ||d                    sJ |                     ||d	                    sJ |                     ||d
                    sJ |                     ||d
d                    sJ |                     ||d                    rJ |                     ||d           ||d	           ||d
          gd           n|                     ||d                    sJ |                     ||dd                    sJ |                     ||dd	                    sJ |                     ||dd
                    sJ |                     ||dd
d                    sJ |                     ||d          d           |                    |d          |rg n|gk    sJ |                    ||dd           |	r|                     ||d                    sJ |                     ||d	                    sJ |                     ||d
                    rJ |                     ||d                    rJ |                     ||d           ||d	          gd           n|                     ||d                    sJ |                     ||dd                    sJ |                     ||dd	                    sJ |                     ||dd
                    rJ |                     ||d          d           |                    |d          |rg n|gk    sJ d S )Nr	   FTr   r   detail	recursiver   subfile2	nesteddir
nestedfile   r0   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_copy_directory_to_existing_directoryz;AbstractCopyTests.test_copy_directory_to_existing_directoryh   sI    /
) 	GFG,,EHHUOOOxx*-udmeT]*K*K A	 A	&L,))A S ,8&A EE!QKKK555..0=ug   
 EE!Q$E''' Ayy!<!<=====yy!<!<=====xx < <=====yyl!K!KLLLLL99WWVX%>%>?????
33
3344
 #      xx 9 9:::::yy:!F!FGGGGGyy:!F!FGGGGGxx+ F FGGGGGyy;!U!UVVVVVggfh//4@@@555..0=ug   
 EE!Q$E333 Ayy!<!<=====yy!<!<=====99WWV[%A%ABBBBB99WWVX%>%>?????
33
33 #      xx 9 9:::::yy:!F!FGGGGGyy:!F!FGGGGG99WWVX{%K%KLLLLLggfh//4@@@555..0=ug    A	 A	r!   c           	          |}|}|                     |           t          ddgddg          D ]\  }}	 ||d          }
|r|
dz  }
 ||d          }|	r|dz  }|                    |
|           |r|                    |          g k    sJ nFt	          j        t                    5  |                    |           d d d            n# 1 swxY w Y   |                    |
|d           |                     ||d                    sJ |                     ||dd                    sJ |                     ||dd                    sJ |                     ||dd	                    sJ |                     ||dd	d
                    sJ |	                     ||d                    rJ |
                     ||d          d           |	                     ||d                    rJ |                    |
|dd           |                     ||d                    sJ |                     ||dd                    sJ |                     ||dd                    sJ |	                     ||dd	                    rJ |	                     ||d                    rJ |
                     ||d          d           |	                     ||d                    rJ d S )NFTr   r   r#   r/   r   r1   r2   r3   r4   r5   )r   r7   r   r8   pytestraisesFileNotFoundErrorr   r   r   r   )r   r   r   r   r   r   r   r   r9   r:   r;   r<   s               r   $test_copy_directory_to_new_directoryz6AbstractCopyTests.test_copy_directory_to_new_directory   s    /
*-udmeT]*K*K %	< %	<&L,))A S))A S EE!QKKK) "uuV}}*****]#455 " "EE&MMM" " " " " " " " " " " " " " " EE!Q$E'''88GGFH556666699WWVXzBBCCCCC99WWVXzBBCCCCC88GGFHkBBCCCCC99WWVX{LQQRRRRRyy!:!:;;;;;EE''&(++tE<<<yy!:!:;;;;; EE!Q$E33388GGFH556666699WWVXzBBCCCCC99WWVXzBBCCCCCyy;!G!GHHHHHyy!:!:;;;;;EE''&(++tE<<<yy!:!:;;;;;;K%	< %	<s   'C		C	C	c           
      d   |}|}|                     |           |s! ||d          }|                    |           |                    |          sJ dD ]X}	|	r|dz   n|}
|                     ||dd          |
           |                     ||d                    sJ |                     ||d                    sJ |                     ||d                    rJ |                     ||dd	                    rJ |                     ||d                    rJ |                     ||d           ||d          gd
           |                    |d          |rg n|gk    sJ t          ddgd
dg          D ] \  }}|                     ||d|          |
|           |                     ||d                    sJ |                     ||d                    sJ |                     ||d                    sJ |                     ||dd	                    sJ |                     ||d                    rJ |                     ||d           ||d           ||d          gd
           |                    |d          |rg n|gk    sJ |                     ||d|          |
|d           |                     ||d                    sJ |                     ||d                    sJ |                     ||d                    rJ |                     ||d                    rJ |                     ||d           ||d          gd
           |                    |d          |rg n|gk    sJ "Zd S )Nr	   FTr   r   *r   r1   r2   r3   Tr/   Fr-   **r4   r5   )	r   r   r   r   r   r   r   r8   r7   )r   r   r   r   r   r   r   r   r	   r:   r<   globr0   s                r   $test_copy_glob_to_existing_directoryz6AbstractCopyTests.test_copy_glob_to_existing_directory   s    /
) 	GFG,,EHHUOOOxx) =	 =	L ,8&A EE''&(C00!44499WWVZ889999999WWVZ8899999xx < <=====yyl!K!KLLLLLyy!:!:;;;;;EEGFJ//GFJ//      555..0=ug   
 $'T{T5M#B#B & &iggfh55qINNNyy!<!<=====yy!<!<=====xx < <=====yyl!K!KLLLLL99WWVX%>%>?????
33
3344
 #     uuVEu224ABB5'   
 GFHd33Q)VW     yy!<!<=====yy!<!<=====99WWV[%A%ABBBBB99WWVX%>%>?????
33
33 #     uuVEu224ABB5'    I&/=	 =	r!   c           
      H   |}|}|                     |           dD ]} ||d          }|r|dz  }|                     ||dd          |           |                     ||d                    sJ |                     ||dd                    sJ |                     ||dd                    sJ |                     ||dd                    rJ |                     ||ddd	                    rJ |                     ||d                    rJ |                     ||dd                    rJ |                     ||d          d
           |                     ||d                    rJ t          ddgd
dg          D ]\  }	}
|                     ||d|	          ||
           |                     ||d                    sJ |                     ||dd                    sJ |                     ||dd                    sJ |                     ||dd                    sJ |                     ||ddd	                    sJ |                     ||d                    rJ |                     ||dd                    rJ |                     ||d          d
           |                     ||d                    rJ |                     ||d|	          ||
d           |                     ||d                    sJ |                     ||dd                    sJ |                     ||dd                    sJ |                     ||dd                    rJ |                     ||d                    rJ |                     ||dd                    rJ |                     ||d          d
           |                     ||d                    rJ d S )NrD   r#   r   r   rE   r   r1   r2   r3   Tr/   rF   Fr4   r5   )r   r   r   r   r   r   r7   )r   r   r   r   r   r   r   r:   r<   rG   r0   s              r   test_copy_glob_to_new_directoryz1AbstractCopyTests.test_copy_glob_to_new_directoryE  s    /
) ,	@ ,	@L))A S EE''&(C00!44488GGFH556666699WWVXzBBCCCCC99WWVXzBBCCCCCyy;!G!GHHHHHyy;!U!UVVVVVyy!:!:;;;;;yy8!D!DEEEEEEE''&(++tE<<<yy!:!:;;;;; $'T{T5M#B#B @ @iggfh55qINNNxx 9 9:::::yy:!F!FGGGGGyy:!F!FGGGGGxx+ F FGGGGGyy;!U!UVVVVV99WWVX%>%>?????99WWVXx%H%HIIIIIggfh//4@@@99WWVX%>%>????? GFHd33Q)VW     xx 9 9:::::yy:!F!FGGGGGyy:!F!FGGGGG99WWVX{%K%KLLLLL99WWVX%>%>?????99WWVXx%H%HIIIIIggfh//4@@@99WWVX%>%>??????3@',	@ ,	@r!   argnames	argvaluesc
                   	 |}
|t          ddgddg          D ]\  }}|                               |r d          n}|r|dz   n|}|                     |
|          |||           |                              }|r	fd|D             }n	fd|D             }t	          |          t	          |          k    sJ 	 |                    d           # t          $ r Y w xY wd S )	NTFr#   r   r5   c           	      <    g | ]}  d |                    S )r#    .0pr   fs_sanitize_pathr   s     r   
<listcomp>z?AbstractCopyTests.test_copy_glob_edge_cases.<locals>.<listcomp>  s@     % % %GH$$WWVXq%A%ABB% % %r!   c                 :    g | ]}  |                    S rO   rO   rP   s     r   rT   z?AbstractCopyTests.test_copy_glob_edge_cases.<locals>.<listcomp>  s>     % % %=>$$WWVQ%7%788% % %r!   r/   )r   r   copyfindsortedr   rA   )r   pathr0   r6   expectedr   r   fs_glob_edge_cases_filesr   rS   r   new_dirr:   r<   outputprefixed_expectedr   s         `  `      @r   test_copy_glob_edge_casesz+AbstractCopyTests.test_copy_glob_edge_cases|  s   " *%,dE]T5M%J%J 	 	!G\HHV-4@)))&A'.CQAGGGGFD))1	HGUUUWWV__F % % % % % %LT% % %!!% % % % % %BJ% % %! &>>V,=%>%>>>>>f----$   +	 	s   C%%
C21C2c           	         |}|}|                     |           |s! ||d          }|                    |           |                    |          sJ  ||d           ||d           ||dd          g}	dD ]}
|
r|dz   n|}|                    |	|           |                     ||d                    sJ |                     ||d                    sJ |                     ||d                    sJ |                     ||d           ||d           ||d          gd	           |                    |d
          |rg n|gk    sJ d S )Nr	   file1r
   r   r   rD   r   Tr/   Fr-   )r   r   r   r   r   r   r8   )r   r   r   r   r   r   r   r   r	   source_filesr:   r<   s               r   -test_copy_list_of_files_to_existing_directoryz?AbstractCopyTests.test_copy_list_of_files_to_existing_directory  s    /
) 	GFG,,EHHUOOOxx GFG$$GFG$$GFHj11
 * 	 	L ,8&AEE,"""99WWVW556666699WWVW556666699WWVZ8899999EEGFG,,GFG,,GFJ//
      555..0=ug    !	 	r!   c                    |}|}|                     |            ||d           ||d           ||dd          g}|                    | ||d          dz              |                     ||d                    sJ |                     ||dd                    sJ |                     ||dd                    sJ |                     ||dd                    sJ d S )Nra   r
   r   r   r#   r   r$   )r   r   r   r   r   r   r   rb   s           r   (test_copy_list_of_files_to_new_directoryz:AbstractCopyTests.test_copy_list_of_files_to_new_directory  s    /
 GFG$$GFG$$GFHj11
 	lGGFH55;<<<xx1122222yy7;;<<<<<yy7;;<<<<<yy:>>???????r!   c                 F   |}|}|                     |          rJ |                     ||d           ||d          g|           |                    |          sJ |                     ||d                    sJ |                     ||d                    sJ d S )Nra   r
   )r   r   r   r   r%   s          r   !test_copy_two_files_new_directoryz3AbstractCopyTests.test_copy_two_files_new_directory  s    
 /99V$$$$$
wwvw'')A)ABFKKKxxyy1122222yy112222222r!   c                    |}|}|                      ||d          |d           |                     ||d                    sJ |                     ||d                    rJ |                     ||d          g           |r|                    |          g k    sJ n|                    |          rJ |                      ||d          |d           |                     ||d                    sJ |                     ||dd                    sJ |                     ||d                    sJ d S )Nr   Tr/   zsubfile.txtz
subdir.txtzsubdir*)r   r   r   r8   r   r   )r   r   r   r   %fs_dir_and_file_with_same_name_prefixr   r   r   s           r   7test_copy_directory_without_files_with_same_name_prefixzIAbstractCopyTests.test_copy_directory_without_files_with_same_name_prefix  su    7 	ggfh''4@@@yy778888899WWV\::;;;;;
wwv}--.///% 	)55==B&&&&&yy((((( 	ggfi((&DAAAxx1122222yy=AABBBBByy667777777r!   c                    |}|}g }g }t          d          D ]}	t          t          |	                              d                                                    }
|                     |||
 d                     |                     |||
 d                     |                    ||           t          d          D ]E}	|                    ||	                                       d          }|t          |	          k    sJ Fd S )N
   zutf-8z.txt)path1path2)	ranger   strencode	hexdigestappendrV   catdecode)r   r   r   r   fs_10_files_with_hashed_namesr   r   rb   destination_filesihashed_ifile_contents               r   -test_copy_with_source_and_destination_as_listz?AbstractCopyTests.test_copy_with_source_and_destination_as_list  s)    / r 	I 	IA3q66==1122<<>>H80A0A0A B BCCC$$WWV5F5F5F%G%GHHHH 	l*;<<<r 	* 	*A66"3A"677>>wGGL3q66)))))	* 	*r!   N)__name__
__module____qualname__r    r&   r)   r+   r=   rB   rH   rJ   r?   markparametrizer   r_   rc   re   rg   rj   r{   rO   r!   r   r   r   	   s-       (* (* (*T@ @ @ 5 5 5*? ? ?T T Tl3< 3< 3<jP P Pd5@ 5@ 5@n [j)k* ' '	 'R+ + +Z@ @ @*3 3 38 8 8>* * * * *r!   r   )hashlibr   	itertoolsr   r?   fsspec.tests.abstract.commonr   r   rO   r!   r   <module>r      s                 > > > > > >d* d* d* d* d* d* d* d* d* d*r!   