
    g'                         d dl Z d dlmZ d dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ  G d	 d
      Z G d de      Zy)    N)md5LocalFileSystem)AbstractCopyTests)AbstractGetTests)AbstractOpenTests)AbstractPipeTests)AbstractPutTestsc                      e Zd ZdZej
                  d        Zej
                  d        Zej
                  d        Zej
                  d        Z	ej
                  d        Z
ej
                  d        Zej
                  d        Zej
                  d	        Zej
                  d
        Zej
                  d        Zd Zd Zd Zd Zy)BaseAbstractFixturesz
    Abstract base class containing fixtures that are used by but never need to
    be overridden in derived filesystem-specific classes to run the abstract
    tests on such filesystems.
    c              #   `   K   | j                  |||      }| |j                  |d       yw)z
        Scenario on remote filesystem that is used for many cp/get/put tests.

        Cleans up at the end of each test it which it is used.
        T	recursiveN_bulk_operations_scenario_0rmselffsfs_joinfs_pathsources        S/var/www/openai/venv/lib/python3.12/site-packages/fsspec/tests/abstract/__init__.pyfs_bulk_operations_scenario_0z2BaseAbstractFixtures.fs_bulk_operations_scenario_0   s1      11"gwG
f%   ,.c              #   `   K   | j                  |||      }| |j                  |d       yw)z
        Scenario on remote filesystem that is used for glob edge cases cp/get/put tests.

        Cleans up at the end of each test it which it is used.
        Tr   N_glob_edge_cases_filesr   r   s        r   fs_glob_edge_cases_filesz-BaseAbstractFixtures.fs_glob_edge_cases_files    s1      ,,R'B
f%r   c              #   `   K   | j                  |||      }| |j                  |d       yw)z
        Scenario on remote filesystem that is used to check cp/get/put on directory
        and file with the same name prefixes.

        Cleans up at the end of each test it which it is used.
        Tr   N#_dir_and_file_with_same_name_prefixr   r   s        r   %fs_dir_and_file_with_same_name_prefixz:BaseAbstractFixtures.fs_dir_and_file_with_same_name_prefix+   s1      99"gwO
f%r   c              #   `   K   | j                  |||      }| |j                  |d       yw)z
        Scenario on remote filesystem that is used to check cp/get/put files order
        when source and destination are lists.

        Cleans up at the end of each test it which it is used.
        Tr   N_10_files_with_hashed_namesr   r   s        r   fs_10_files_with_hashed_namesz2BaseAbstractFixtures.fs_10_files_with_hashed_names7   s1      11"gwG
f%r   c              #   p   K    ||d      }| |j                  |      r|j                  |d       yyw)z
        Return name of remote directory that does not yet exist to copy into.

        Cleans up at the end of each test it which it is used.
        targetTr   Nexistsr   )r   r   r   r   r)   s        r   	fs_targetzBaseAbstractFixtures.fs_targetC   s:      (+99VEE&DE)    46c              #   `   K   | j                  |||      }| |j                  |d       yw)z
        Scenario on local filesystem that is used for many cp/get/put tests.

        Cleans up at the end of each test it which it is used.
        Tr   Nr   r   local_fs
local_join
local_pathr   s        r    local_bulk_operations_scenario_0z5BaseAbstractFixtures.local_bulk_operations_scenario_0O   s1      11(J
SFd+r   c              #   `   K   | j                  |||      }| |j                  |d       yw)z
        Scenario on local filesystem that is used for glob edge cases cp/get/put tests.

        Cleans up at the end of each test it which it is used.
        Tr   Nr   r/   s        r   local_glob_edge_cases_filesz0BaseAbstractFixtures.local_glob_edge_cases_filesZ   s1      ,,Xz:NFd+r   c              #   `   K   | j                  |||      }| |j                  |d       yw)z
        Scenario on local filesystem that is used to check cp/get/put on directory
        and file with the same name prefixes.

        Cleans up at the end of each test it which it is used.
        Tr   Nr!   r/   s        r   (local_dir_and_file_with_same_name_prefixz=BaseAbstractFixtures.local_dir_and_file_with_same_name_prefixe   s6      99j*
 Fd+r   c              #   `   K   | j                  |||      }| |j                  |d       yw)z
        Scenario on local filesystem that is used to check cp/get/put files order
        when source and destination are lists.

        Cleans up at the end of each test it which it is used.
        Tr   Nr%   r/   s        r    local_10_files_with_hashed_namesz5BaseAbstractFixtures.local_10_files_with_hashed_namesu   s1      11(J
SFd+r   c              #   p   K    ||d      }| |j                  |      r|j                  |d       yyw)z
        Return name of local directory that does not yet exist to copy into.

        Cleans up at the end of each test it which it is used.
        r)   Tr   Nr*   )r   r0   r1   r2   r)   s        r   local_targetz!BaseAbstractFixtures.local_target   s:      J1??6"KK$K/ #r-   c                 t    ||d      }|j                   ||d             |j                   ||d             t        d      D ]p  } ||d|       } ||d      }|j                  |       |j                   ||d             |j                   ||d             |j                   ||d	             r |S )
uL  
        Scenario that is used for glob edge cases cp/get/put tests.
        Creates the following directory and file structure:

        📁 source
        ├── 📄 file1
        ├── 📄 file2
        ├── 📁 subdir0
        │   ├── 📄 subfile1
        │   ├── 📄 subfile2
        │   └── 📁 nesteddir
        │       └── 📄 nestedfile
        └── 📁 subdir1
            ├── 📄 subfile1
            ├── 📄 subfile2
            └── 📁 nesteddir
                └── 📄 nestedfile
        r   file1file2   subdir	nesteddirsubfile1subfile2
nestedfile)touchrangemakedirs)r   some_fs	some_join	some_pathr   
subdir_idxr@   rA   s           r   r   z+BaseAbstractFixtures._glob_edge_cases_files   s    & 9h/i01i01(Jv
|'<=F!&+6IY'MM)FJ78MM)FJ78MM)I|<= #     c                 N    ||d      } ||d      } ||d      }|j                  |       |j                   ||d             |j                   ||d             |j                   ||d             |j                   ||d             |j                   ||d             |S )	u  
        Scenario that is used for many cp/get/put tests. Creates the following
        directory and file structure:

        📁 source
        ├── 📄 file1
        ├── 📄 file2
        └── 📁 subdir
            ├── 📄 subfile1
            ├── 📄 subfile2
            └── 📁 nesteddir
                └── 📄 nestedfile
        r   r@   rA   r=   r>   rB   rC   rD   rG   rE   )r   rH   rI   rJ   r   r@   rA   s          r   r   z0BaseAbstractFixtures._bulk_operations_scenario_0   s     9h/68,fk2	#i01i01i
34i
34i	<89rL   c                      ||d      } ||d      } ||d      } ||d      }|j                  |       |j                  |       |j                  |       |S )u&  
        Scenario that is used to check cp/get/put on directory and file with
        the same name prefixes. Creates the following directory and file structure:

        📁 source
        ├── 📄 subdir.txt
        └── 📁 subdir
            └── 📄 subfile.txt
        r   r@   z
subdir.txtzsubfile.txtrN   )r   rH   rI   rJ   r   r@   filesubfiles           r   r"   z8BaseAbstractFixtures._dir_and_file_with_same_name_prefix   s_     9h/68,.FM2 dgrL   c                      ||d      }t        d      D ]a  }t        t        |      j                  d            j	                         } ||| d      }|j                  || j                                c |S )u   
        Scenario that is used to check cp/get/put files order when source and
        destination are lists. Creates the following directory and file structure:

        📁 source
        └── 📄 {hashed([0-9])}.txt
        r   
   zutf-8z.txt)pathvalue)rF   r   strencode	hexdigestpipe)r   rH   rI   rJ   r   ihashed_irT   s           r   r&   z0BaseAbstractFixtures._10_files_with_hashed_names   sp     9h/rA3q6==12<<>HVz%67DLLdQC--/L:  rL   N)__name__
__module____qualname____doc__pytestfixturer   r   r#   r'   r,   r3   r5   r7   r9   r;   r   r   r"   r&    rL   r   r   r      s    ^^& & ^^& & ^^	& 	& ^^	& 	& ^^	* 	* ^^, , ^^, , ^^, , ^^	, 	, ^^	0 	0B2&rL   r   c                   >   e Zd ZdZej
                  d        Zej
                  d        Zej
                  d        Z ej
                  d      d        Z	ej
                  d        Z
ej
                  d	        Zej
                  d
        Zej
                  d        Zy)AbstractFixturesa}  
    Abstract base class containing fixtures that may be overridden in derived
    filesystem-specific classes to run the abstract tests on such filesystems.

    For any particular filesystem some of these fixtures must be overridden,
    such as ``fs`` and ``fs_path``, and others may be overridden if the
    default functions here are not appropriate, such as ``fs_join``.
    c                     t        d      Nz3This function must be overridden in derived classesNotImplementedErrorr   s    r   r   zAbstractFixtures.fs       !"WXXrL   c                 6    t         j                  j                  S )z
        Return a function that joins its arguments together into a path.

        Most fsspec implementations join paths in a platform-dependent way,
        but some will override this to always use a forward slash.
        osrT   joinri   s    r   r   zAbstractFixtures.fs_join   s     ww||rL   c                     t        d      rf   rg   ri   s    r   r   zAbstractFixtures.fs_path  rj   rL   class)scopec                     t        d      S )NT)
auto_mkdirr   ri   s    r   r0   zAbstractFixtures.local_fs  s     $//rL   c                 6    t         j                  j                  S )zs
        Return a function that joins its arguments together into a path, on
        the local filesystem.
        rl   ri   s    r   r1   zAbstractFixtures.local_join  s     ww||rL   c                     |S Nrb   )r   tmpdirs     r   r2   zAbstractFixtures.local_path  s    rL   c                      y)zP
        Return whether this implementation supports empty directories.
        Trb   ri   s    r   supports_empty_directoriesz+AbstractFixtures.supports_empty_directories  s    
 rL   c                     d S )Nc                     | S rv   rb   )xs    r   <lambda>z3AbstractFixtures.fs_sanitize_path.<locals>.<lambda>!  s    rL   rb   ri   s    r   fs_sanitize_pathz!AbstractFixtures.fs_sanitize_path  s    rL   N)r\   r]   r^   r_   r`   ra   r   r   r   r0   r1   r2   ry   r~   rb   rL   r   rd   rd      s     ^^Y Y ^^  ^^Y Y V^^'"0 #0
 ^^  ^^  ^^  ^^ rL   rd   )rm   hashlibr   r`   fsspec.implementations.localr   fsspec.tests.abstract.copyr   fsspec.tests.abstract.getr   fsspec.tests.abstract.openr   fsspec.tests.abstract.piper	   fsspec.tests.abstract.putr
   r   rd   rb   rL   r   <module>r      s:    	   8 8 6 8 8 6Y Yx7+ 7rL   