
    gQ                     P    d dl mZ d dlmZ d dlZd dlmZ d dlmZ  G d d      Z	y)    )md5)productN)make_path_posix)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)AbstractGetTestsc                    |}|}|j                  |       |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file2subfile1subdir/)mkdirisdirgetisfilermexists)selffsfs_joinfs_bulk_operations_scenario_0local_fs
local_joinlocal_targetsourcetargettarget_file2target_subfile1s              N/var/www/openai/venv/lib/python3.12/site-packages/fsspec/tests/abstract/get.py#test_get_file_to_existing_directoryz4AbstractGetTests.test_get_file_to_existing_directory   s;    /v~~f%%%!&'2$VZ8 	wvw'0|,,, 	wvx4f=/// 	\?34??<000???333 	wvw'#6~~f%%%|,,,
wvx4fslC///    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   r   s	            r   test_get_file_to_new_directoryz/AbstractGetTests.test_get_file_to_new_directory3   s     /v
FHj1:fi3P	
 ~~f%%%~~j:;;;z&(JGHHHr!   c                     |}|}|j                  |       |j                   ||dd       ||d             |j                   ||d            sJ y )Nr   r   newfile)r   r   r   r%   s	            r   +test_get_file_to_file_in_existing_directoryz<AbstractGetTests.test_get_file_to_file_in_existing_directoryJ   sQ     /v
wvx4j6STz&)<===r!   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_get_file_to_file_in_new_directoryz7AbstractGetTests.test_get_file_to_file_in_new_directory\   st     /v
FHj1vx3	
 ~~j:;;;z&(IFGGGr!   c           	      ~   |}|}|j                  |       |j                  |      sJ t        ddgddg      D ]  \  }	}
 ||d      }|	r|dz  }|
r|dz   n|}|j                  ||       |j	                  |      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	                  |      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	                  |      g k(  rJ  y )NFTr   r   	recursiver   subfile2	nesteddir
nestedfile   r.   maxdepth)r   r   zipr   lsr   r   r   r   r   r   r   r   r   r   r   r   source_slashtarget_slashsts                r   (test_get_directory_to_existing_directoryz9AbstractGetTests.test_get_directory_to_existing_directoryr   sl    /v~~f%%%*-udmeT]*K&L,)AS ,&A FF1aL;;v&",,, FF1a4F(z&*'EFFFz&*'EFFF~~j&EFFFz&+|'TUUU#??:fh+GHHH"6:6"6:6"6;7
 #    ~~j&BCCCz&(J'OPPPz&(J'OPPP~~j;&OPPPvxlK   Jvx8DI;;v&",,, FF1a4!F4z&*'EFFFz&*'EFFF#??:fk+JKKK#??:fh+GHHH"6:6"6:6 #    ~~j&BCCCz&(J'OPPPz&(J'OPPP#??:fh+TUUUJvx8DI;;v&",,,{ +Lr!   c           	      X   |}|}|j                  |       t        ddgddg      D ]  \  }	}
 ||d      }|	r|dz  } ||d      }|
r|dz  }|j                  ||       |j                  |      g k(  sJ |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                  |      g k(  s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 )NFTr   r   r#   r-   r   r/   r0   r1   r2   r3   )r   r5   r   r6   r   r   r   r   r7   s                r   #test_get_directory_to_new_directoryz4AbstractGetTests.test_get_directory_to_new_directory   sD    /v*-udmeT]*K&L,)AS68,AS FF1aL;;v&",,, FF1a4F(>>*VX">?????:fh
#KLLL??:fh
#KLLL>>*VX{"KLLL??68[,G    z&('CDDDKK
684KE;;v&",,, FF1a4!F4>>*VX">?????:fh
#KLLL??:fh
#KLLLz&(K'PQQQz&('CDDDKK
684KEz&('CDDDG +Lr!   c           
      n   |}|}|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                  |      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                  |      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                  |      g k(  rJ   y )NFTr   r   *r   r/   r0   r1   Tr-   **Fr2   r3   )r   r   r   r   r   r   r6   r5   r   r   r   r   r   r   r   r   r   r9   r;   globr.   s                r   #test_get_glob_to_existing_directoryz4AbstractGetTests.test_get_glob_to_existing_directory   s    /v)L ,&A FF768S115??:fj#ABBB??:fj#ABBB~~j&EFFFz&+|'TUUUz&('CDDDKKvz2vz2    ;;v&",,, $'T{T5M#Biwvx6YOz&*'EFFFz&*'EFFF~~j&EFFFz&+|'TUUU#??:fh+GHHH"6:6"6:6"6;7
 #    {{6*b000 FHd3Q)VW    z&*'EFFFz&*'EFFF#??:fk+JKKK#??:fh+GHHH"6:6"6:6 #    {{6*b000E $C+ *r!   c           
         |}|}|j                  |       dD ]:  }	 ||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                  |      g k(  s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                  |j                  |d      d
       |j	                   ||d            sJ  = y )Nr@   r#   r   r   rA   r   r/   r0   r1   Tr-   rB   Fr2   r3   )detail)r   r   r   r   r   r   r6   r5   rC   s                r   test_get_glob_to_new_directoryz/AbstractGetTests.test_get_glob_to_new_directory=  sr    /v)L)AS FF768S115>>*VX">?????:fh
#KLLL??:fh
#KLLLz&(K'PQQQ68[,G    z&('CDDDz&(H'MNNNKK
684KE;;v&",,, $'T{T5M#Biwvx6YO~~j&BCCCz&(J'OPPPz&(J'OPPP~~j;&OPPPvxlK   $??:fh+GHHH#??:fh+QRRRJvx8DI#??:fh+GHHH FHd3Q)VW    ~~j&BCCCz&(J'OPPPz&(J'OPPP#??:fh+TUUU#??:fh+GHHH#??:fh+QRRRHKKuK=N#??:fh+GHHH7 $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]  }t	         |	|d|             }}n|D cg c]  }t	         |	||             }}t        |      t        |      k(  sJ 	 |j                  |d        y c c}w c c}w # t        $ r Y w xY w)NTFr#   r   r3   r-   )r   r   r   findr   sortedr   FileNotFoundError)r   pathr.   r4   expectedr   r   fs_glob_edge_cases_filesr   r   r   r   r   new_dirr9   r;   outputpprefixed_expecteds                      r   test_get_glob_edge_casesz)AbstractGetTests.test_get_glob_edge_cases~  s%   $ *%,dE]T5M%J!G\NN6"07
68,VA'CQAFF764(!y8FT]]6*FNV%NVOJvx$CDh " %
 EM%DLqOJvq$9:H " % &>V,=%>>>>Fd3) &K%% % s   5C!C&C++	C76C7c           	         |}|}|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	                  |      g k(  rJ  y )	Nfile1r
   r   r   r@   r   Tr-   )r   r   r   r   r6   )r   r   r   r   r   r   r   r   r   source_filesr9   r;   s               r   ,test_get_list_of_files_to_existing_directoryz=AbstractGetTests.test_get_list_of_files_to_existing_directory  s    /v FG$FG$FHj1
 *L ,&AFF<#??:fg#>?????:fg#>?????:fj#ABBBKKvw/vw/vz2
    ;;v&",,,! *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 )NrX   r
   r   r   r#   r   r$   )
r   r   r   r   r   r   r   r   r   rY   s
             r   'test_get_list_of_files_to_new_directoryz8AbstractGetTests.test_get_list_of_files_to_new_directory  s     /v FG$FG$FHj1
 	|Z9C?@~~j:;;;z&(GDEEEz&(GDEEEz&(JGHHHr!   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   touchr   ranger   r   r   r   )r   r   r   fs_pathr   r   r   r^   src_filer   loops              r   test_get_directory_recursivez-AbstractGetTests.test_get_directory_recursive  s   
 gu%3'

 ??6***!HDFF3$F/>>&)))qyz&&'ABBB#??:fe+DEEEz&&'ABBB~~j&?@@@z&%'HIII  	Fd+ ??6***!HDFF39fF5>>&)))??:ff#=>>>z&%'@AAA	 r!   c                    |}|}|j                   ||d      |d       |j                   ||d            sJ |j                   ||d            rJ |j                   ||d      g       |j                  |      g k(  s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   r6   r   )	r   r   r   r   r   r   %fs_dir_and_file_with_same_name_prefixr   r   s	            r   6test_get_directory_without_files_with_same_name_prefixzGAbstractGetTests.test_get_directory_without_files_with_same_name_prefix  s     7 	wvx(&DAz&-@AAA??:fl#CDDDZ678{{6"b((( 	wvy)6TB~~j:;;;z&(MJKKKz&,?@@@r!   c           
         |}|}g }	g }
t        d      D ]r  }t        t        |      j                  d            j	                         }|	j                   ||| d             |
j                  t         ||| d                   t |j                  |	|
       t        d      D ]5  }|j                  |
|         j                  d      }|t        |      k(  r5J  y )N
   zutf-8z.txt)rpathlpath)
rb   r   strencode	hexdigestappendr   r   catdecode)r   r   r   r   r   r   fs_10_files_with_hashed_namesr   r   rY   destination_filesihashed_ifile_contents                 r   ,test_get_with_source_and_destination_as_listz=AbstractGetTests.test_get_with_source_and_destination_as_list/  s     / rA3q6==12<<>H8*D0A BC$$
6hZt3D EF  	\):;rA#<<(9!(<=DDWML3q6))) r!   N)__name__
__module____qualname__r    r&   r)   r+   r<   r>   rE   rH   pytestmarkparametrizer   rV   rZ   r\   rf   ri   ry    r!   r   r   r   
   s    &0PI.>$H,M-^2EhF1P?IB [[j)k*(	(T%-NI6"BHA:*r!   r   )
hashlibr   	itertoolsr   r}   fsspec.implementations.localr   fsspec.tests.abstract.commonr   r   r   r!   r   <module>r      s        8 >A	* A	*r!   