o
    NZh,'                     @   sn   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 G dd dZG d	d
 d
eZdS )    N)md5LocalFileSystem)AbstractCopyTests)AbstractGetTests)AbstractPutTestsc                   @   s   e Zd ZdZejdd Zejdd Zejdd Zejdd	 Z	ejd
d Z
ejdd Zejdd Zejdd Zejdd Zejdd Zdd Zdd Zdd Zdd ZdS )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                 c   (    |  |||}|V  |j|dd dS )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source r   U/var/www/html/lang_env/lib/python3.10/site-packages/fsspec/tests/abstract/__init__.pyfs_bulk_operations_scenario_0      z2BaseAbstractFixtures.fs_bulk_operations_scenario_0c                 c   r	   )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   r   r   r   fs_glob_edge_cases_files   r   z-BaseAbstractFixtures.fs_glob_edge_cases_filesc                 c   r	   )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   r   r   r   %fs_dir_and_file_with_same_name_prefix)      z:BaseAbstractFixtures.fs_dir_and_file_with_same_name_prefixc                 c   r	   )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   r   r   r   fs_10_files_with_hashed_names5   r   z2BaseAbstractFixtures.fs_10_files_with_hashed_namesc                 c   2    ||d}|V  | |r|j|dd dS dS )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$   r   r   r   	fs_targetA      

zBaseAbstractFixtures.fs_targetc                 c   r	   )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   r   r   r    local_bulk_operations_scenario_0M   r   z5BaseAbstractFixtures.local_bulk_operations_scenario_0c                 c   r	   )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)   r   r   r   local_glob_edge_cases_filesX   r   z0BaseAbstractFixtures.local_glob_edge_cases_filesc                 c   r	   )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)   r   r   r   (local_dir_and_file_with_same_name_prefixc   s   
z=BaseAbstractFixtures.local_dir_and_file_with_same_name_prefixc                 c   r	   )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)   r   r   r    local_10_files_with_hashed_namess   r   z5BaseAbstractFixtures.local_10_files_with_hashed_namesc                 c   r#   )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   r*   r+   r,   r$   r   r   r   local_target   r(   z!BaseAbstractFixtures.local_targetc                 C   s   ||d}| ||d | ||d tdD ],}||d| }||d}|| | ||d | ||d | ||d	 q|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   Z
subdir_idxr5   r6   r   r   r   r      s   


z+BaseAbstractFixtures._glob_edge_cases_filesc                 C   s|   ||d}||d}||d}| | |||d |||d |||d |||d |||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   r5   r6   r2   r3   r7   r8   r9   r<   r:   )r   r=   r>   r?   r   r5   r6   r   r   r   r      s   



z0BaseAbstractFixtures._bulk_operations_scenario_0c                 C   sJ   ||d}||d}||d}||d}| | || || |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   r5   z
subdir.txtzsubfile.txtr@   )r   r=   r>   r?   r   r5   fileZsubfiler   r   r   r      s   







z8BaseAbstractFixtures._dir_and_file_with_same_name_prefixc                 C   sX   ||d}t dD ] }tt|d }||| d}|j|| dd q	|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)r;   r   strencode	hexdigestpipe)r   r=   r>   r?   r   iZhashed_irC   r   r   r   r!      s   
z0BaseAbstractFixtures._10_files_with_hashed_namesN)__name__
__module____qualname____doc__pytestfixturer   r   r   r"   r'   r-   r.   r/   r0   r1   r   r   r   r!   r   r   r   r   r      s4    













!r   c                   @   s   e Zd ZdZejdd Zejdd Zejdd Zejdd	d
d Z	ejdd Z
ejdd Zejdd Zejdd ZdS )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                 C      t dNz3This function must be overridden in derived classesNotImplementedErrorr   r   r   r   r         zAbstractFixtures.fsc                 C      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.
        osrC   joinrU   r   r   r   r      s   zAbstractFixtures.fs_joinc                 C   rQ   rR   rS   rU   r   r   r   r      rV   zAbstractFixtures.fs_pathclass)scopec                 C   s
   t ddS )NT)Z
auto_mkdirr   rU   r   r   r   r*     s   
zAbstractFixtures.local_fsc                 C   rW   )zs
        Return a function that joins its arguments together into a path, on
        the local filesystem.
        rX   rU   r   r   r   r+   
  s   zAbstractFixtures.local_joinc                 C   s   |S Nr   )r   Ztmpdirr   r   r   r,     s   zAbstractFixtures.local_pathc                 C   s   dS )zP
        Return whether this implementation supports empty directories.
        Tr   rU   r   r   r   supports_empty_directories  s   z+AbstractFixtures.supports_empty_directoriesc                 C   s   dd S )Nc                 S   s   | S r]   r   )xr   r   r   <lambda>  s    z3AbstractFixtures.fs_sanitize_path.<locals>.<lambda>r   rU   r   r   r   fs_sanitize_path  rV   z!AbstractFixtures.fs_sanitize_pathN)rJ   rK   rL   rM   rN   rO   r   r   r   r*   r+   r,   r^   ra   r   r   r   r   rP      s$    	

	





rP   )rY   hashlibr   rN   Zfsspec.implementations.localr   Zfsspec.tests.abstract.copyr   Zfsspec.tests.abstract.getr   Zfsspec.tests.abstract.putr   r   rP   r   r   r   r   <module>   s     ]