o
    TZh
                     @   sH  U d dl Z d dlZd dlZd dlZd dlmZ d dlZd dlZd dlm	Z	 ddl
mZ ddlmZ e jdduZerAdd	lmZ ejejejejejgZeej ed
< eD ]#Zejejv rpejej eurpedej d ejejedd qVedde de fddZ!dej"de#fddZ$dej"de de fddZ%dddZ&dS )    N)List)LocalFileSystem   )
deprecated   )compressionZs3fs)S3FileSystemCOMPRESSION_FILESYSTEMSz*A filesystem protocol was already set for z and will be overwritten.T)clobberzuThis function is deprecated and will be removed in a future version. Please use `fsspec.core.strip_protocol` instead.dataset_pathreturnc                 C   s   d| v r|  dd } | S )z
    Preprocesses `dataset_path` and removes remote filesystem (e.g. removing `s3://`).

    Args:
        dataset_path (`str`):
            Path (e.g. `dataset/train`) or remote uri (e.g. `s3://my-bucket/dataset/train`) of the dataset directory.
    z://r   )split)r    r   T/var/www/html/lang_env/lib/python3.10/site-packages/datasets/filesystems/__init__.pyextract_path_from_uri#   s   r   fsc                 C   s   t | t S )z
    Checks if `fs` is a remote filesystem.

    Args:
        fs (`fsspec.spec.AbstractFileSystem`):
            An abstract super-class for pythonic file-systems, e.g. `fsspec.filesystem('file')` or [`datasets.filesystems.S3FileSystem`].
    )
isinstancer   )r   r   r   r   is_remote_filesystem3   s   r   srcdstc                 C   s8   t | st| || | dS | j||dd dS )z2
    Renames the file `src` in `fs` to `dst`.
    T)	recursiveN)r   shutilmoveZ_strip_protocolmv)r   r   r   r   r   r   rename>   s   r   c                   C   sB   t tjdrtj  dS dtjjd< dtjjd< t tj_dS )z
    Clear reference to the loop and thread.
    This is necessary otherwise HTTPFileSystem hangs in the ML training loop.
    Only required for fsspec >= 0.9.0
    See https://github.com/fsspec/gcsfs/issues/379
    
reset_lockNr   )	hasattrfsspecZasynr   Ziothreadloop	threadingLocklockr   r   r   r   _reset_fsspec_lockI   s
   r"   )r   N)'	importlibr   r   warningstypingr   r   Zfsspec.asynZfsspec.implementations.localr   Zutils.deprecation_utilsr    r   util	find_specZ	_has_s3fsZs3filesystemr   ZBz2FileSystemZGzipFileSystemZLz4FileSystemZXzFileSystemZZstdFileSystemr	   ZBaseCompressedFileFileSystem__annotations__Zfs_classprotocolregistrywarnZregister_implementationstrr   ZAbstractFileSystemboolr   r   r"   r   r   r   r   <module>   s<   
 	