o
    g'                     @   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   U/var/www/visachat/venv/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   
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.txtrC   )r   r?   r@   rA   r   r7   file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   ihashed_irG   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.
        osrG   joinrZ   r   r   r   r      s   zAbstractFixtures.fs_joinc                 C   rV   rW   rX   rZ   r   r   r   r     r[   zAbstractFixtures.fs_pathclass)scopec                 C   s
   t ddS )NT)
auto_mkdirr   rZ   r   r   r   r,     s   
zAbstractFixtures.local_fsc                 C   r\   )zs
        Return a function that joins its arguments together into a path, on
        the local filesystem.
        r]   rZ   r   r   r   r-     s   zAbstractFixtures.local_joinc                 C   s   |S Nr   )r   tmpdirr   r   r   r.     s   zAbstractFixtures.local_pathc                 C   s   dS )zP
        Return whether this implementation supports empty directories.
        Tr   rZ   r   r   r   supports_empty_directories  s   z+AbstractFixtures.supports_empty_directoriesc                 C   s   dd S )Nc                 S   s   | S rc   r   )xr   r   r   <lambda>!  s    z3AbstractFixtures.fs_sanitize_path.<locals>.<lambda>r   rZ   r   r   r   fs_sanitize_path  r[   z!AbstractFixtures.fs_sanitize_pathN)rO   rP   rQ   rR   rS   rT   r   r   r   r,   r-   r.   re   rh   r   r   r   r   rU      s$    	

	





rU   )r^   hashlibr   rS   fsspec.implementations.localr   fsspec.tests.abstract.copyr   fsspec.tests.abstract.getr   fsspec.tests.abstract.openr   fsspec.tests.abstract.piper   fsspec.tests.abstract.putr	   r
   rU   r   r   r   r   <module>   s     ]