o
    _Zh'                     @   s   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
 d
ZG dd deZdS )    N)md5LocalFileSystem)AbstractCopyTests)AbstractGetTests)AbstractOpenTests)AbstractPipeTests)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   M/var/www/auris/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_names7   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_targetC      

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_0O   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_filesZ   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_prefixe   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_namesu   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_idxr7   r8   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   r7   r8   r4   r5   r9   r:   r;   r>   r<   )r   r?   r@   rA   r   r7   r8   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   r7   z
subdir.txtzsubfile.txtrB   )r   r?   r@   rA   r   r7   fileZsubfiler   r   r   r      s   







z8BaseAbstractFixtures._dir_and_file_with_same_name_prefixc                 C   sV   ||d}t dD ]}tt|d }||| d}|j||  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@   rA   r   iZhashed_irE   r   r   r   r#      s   
z0BaseAbstractFixtures._10_files_with_hashed_namesN)__name__
__module____qualname____doc__pytestfixturer   r   r    r$   r)   r/   r0   r1   r2   r3   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.
        osrE   joinrW   r   r   r   r      s   zAbstractFixtures.fs_joinc                 C   rS   rT   rU   rW   r   r   r   r     rX   zAbstractFixtures.fs_pathclass)scopec                 C   s
   t ddS )NT)Z
auto_mkdirr   rW   r   r   r   r,     s   
zAbstractFixtures.local_fsc                 C   rY   )zs
        Return a function that joins its arguments together into a path, on
        the local filesystem.
        rZ   rW   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   rW   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   rW   r   r   r   fs_sanitize_path  rX   z!AbstractFixtures.fs_sanitize_pathN)rL   rM   rN   rO   rP   rQ   r   r   r   r,   r-   r.   r`   rc   r   r   r   r   rR      s$    	

	





rR   )r[   hashlibr   rP   Zfsspec.implementations.localr   Zfsspec.tests.abstract.copyr   Zfsspec.tests.abstract.getr   Zfsspec.tests.abstract.openr   Zfsspec.tests.abstract.piper   Zfsspec.tests.abstract.putr	   r
   rR   r   r   r   r   <module>   s     ]