
    çgR                     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 )AbstractPutTestsc                 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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              U/var/www/html/ai-engine/env/lib/python3.11/site-packages/fsspec/tests/abstract/put.py#test_put_file_to_existing_directoryz4AbstractPutTests.test_put_file_to_existing_directory
   s    2
) 	/HHWWVW--...xxwvw//!'&*55 	zz&'**F333yy&&&&& 	zz&(J77@@@yy))))) 	|_-...99\*****99_----- 	zz&'**FSL999xxyy&&&&&
zz&(J77#FFF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   r   s           r    test_put_file_to_new_directoryz/AbstractPutTests.test_put_file_to_new_directory5   s     2

Jvx44ggfi6P6P	
 	
 	
 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   r   s	            r    +test_put_file_to_file_in_existing_directoryz<AbstractPutTests.test_put_file_to_file_in_existing_directoryE   s     2
) 	/HHWWVW--...xx
zz&(J779S9STTT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_put_file_to_file_in_new_directoryz7AbstractPutTests.test_put_file_to_file_in_new_directory[   s     2

Jvx44GFHi00	
 	
 	
 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   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   sI    2
) 	GFG,,EHHUOOOxx*-udmeT]*K*K A	 A	&L,))A S ,8&A FF1aLLL555..0=ug   
 FF1a4F((( 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   
 FF1a4!F444 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$   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   s    2
*-udmeT]*K*K %	< %	<&L,))A S))A S FF1aLLL) "uuV}}*****]#455 " "EE&MMM" " " " " " " " " " " " " " " FF1a4F(((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!:!:;;;;; FF1a4!F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!:!:;;;;;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   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   s    2
) 	GFG,,EHHUOOOxx) @	 @	L ,8&A FF::fh44a888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zz&(D991	RRRyy!<!<=====yy!<!<=====xx < <=====yyl!K!KLLLLL99WWVX%>%>?????
33
3344
 #     uuVEu224ABB5'   
 Jvx66'	     yy!<!<=====yy!<!<=====99WWV[%A%ABBBBB99WWVX%>%>?????
33
33 #     uuVEu224ABB5'    O)/@	 @	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 )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44a888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zz&(D991	RRR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%>%>????? Jvx66'	     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%>%>??????9@'/	@ /	@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   r6   c           	      <    g | ]}  d |                    S )r$    .0pr   fs_sanitize_pathr   s     r    
<listcomp>z=AbstractPutTests.test_put_glob_edge_cases.<locals>.<listcomp>  s@     % % %GH$$WWVXq%A%ABB% % %r"   c                 :    g | ]}  |                    S rP   rP   rQ   s     r    rU   z=AbstractPutTests.test_put_glob_edge_cases.<locals>.<listcomp>  s>     % % %=>$$WWVQ%7%788% % %r"   r0   )r   r   r   findsortedr   rB   )r   pathr1   r7   expectedr   r   r   local_glob_edge_cases_filesr   rT   r   new_dirr;   r=   outputprefixed_expectedr   s         `   `      @r    test_put_glob_edge_casesz)AbstractPutTests.test_put_glob_edge_cases  s   $ -%,dE]T5M%J%J 	 	!G\HHV-4@)))&A'.CQAFF::fd++Q)hFWWW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   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  s    2
) 	GFG,,EHHUOOOxx Jvw''Jvw''Jvx44
 * 	 	L ,8&AFF<###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   r   rb   s	            r    'test_put_list_of_files_to_new_directoryz8AbstractPutTests.test_put_list_of_files_to_new_directory  s    2
 Jvw''Jvw''Jvx44
 	|WWVX66<===xx1122222yy7;;<<<<<yy7;;<<<<<yy:>>???????r"   c                      ||d          } ||d          }|                     |           |                    |           |}	|                    |	          rJ t          d          D ]}
|                    ||	d           |                    |	          sJ |
dk    rC|                     ||	d                    sJ |                     ||	d                    rJ z|                     ||	d                    sJ |                     ||	d                    sJ |                     ||	dd                    sJ |                    |	d           |                    |	          rJ t          d          D ]v}
|                    |dz   |	d           |                    |	          sJ |                     ||	d                    sJ |                     ||	d                    rJ wd S )Nsrcfile   Tr0   r   r   )r   r   r   ranger   r   r   r   )r   r   r   r   local_fsr   
local_pathrg   src_filer   loops              r    test_put_directory_recursivez-AbstractPutTests.test_put_directory_recursive  sC   
 jU++:c6**sx    99V$$$$$!HH 
	A 
	ADFF3$F///88F#####qyyyy!8!89999999WWVU%;%;<<<<<<yy!8!899999xx 6 677777yy!?!?@@@@@@
f%%% 99V$$$$$!HH 	9 	9DFF39fF55588F#####99WWVV4455555yy!7!7888888		9 	9r"   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   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  su    : 	zz&(++Y$GGGyyM::;;;;;99WWY==>>>>>
wwv}--.///% 	)55==B&&&&&yy((((( 	zz&),,i4HHHxx	84455555yyHmDDEEEEEyyL99:::::::r"   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)lpathrpath)	rj   r   strencode	hexdigestappendr   catdecode)r   r   r   r   r    local_10_files_with_hashed_namesr   r   rb   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 	IA3q66==1122<<>>H

6h3D3D3D E EFFF$$WWV5F5F5F%G%GHHHH 	\):;;;r 	* 	*A66"3A"677>>wGGL3q66)))))	* 	*r"   N)__name__
__module____qualname__r!   r'   r*   r,   r>   rC   rI   rK   r@   markparametrizer   r_   rc   re   ro   rr   r   rP   r"   r    r   r   	   s/       )* )* )*V@ @ @ 5 5 5,? ? ? T T Tl3< 3< 3<jT T Tl8@ 8@ 8@t [j)k* ( (	 (T, , ,\@ @ @*"9 "9 "9H; ; ;@* * * * *r"   r   )hashlibr   	itertoolsr   r@   fsspec.tests.abstract.commonr   r   rP   r"   r    <module>r      s                 > > > > > >F	* F	* F	* F	* F	* F	* F	* F	* F	* F	*r"   