


"""simple docstring"""


import importlib
import shutil
import threading
import warnings
from typing import List

import fsspec
import fsspec.asyn

from . import compression
from .hffilesystem import HfFileSystem


A     :   Optional[int]			    =			importlib.util.find_spec("s3fs") is not None

if _has_safs:
	from .safilesystem import SaFileSystem  # noqa: F401

A     :   Union[str, Any]			    =			[
    compression.BzaFileSystem,
    compression.GzipFileSystem,
    compression.LzaFileSystem,
    compression.XzFileSystem,
    compression.ZstdFileSystem,
]

# Register custom filesystems
for fs_class in COMPRESSION_FILESYSTEMS + [HfFileSystem]:
	if fs_class.protocol in fsspec.registry and fsspec.registry[fs_class.protocol] is not fs_class:
		warnings.warn(f'''A filesystem protocol was already set for {fs_class.protocol} and will be overwritten.''')
	fsspec.register_implementation(fs_class.protocol, fs_class, clobber=True)


def _lowerCamelCase	(		_UpperCamelCase      ):

			'''simple docstring'''




			if "://" in dataset_path:
						__lowerCAmelCase				    =			dataset_path.split("://"      )[1]
			return dataset_path


def _lowerCamelCase	(		_UpperCamelCase      ):

			'''simple docstring'''




			if fs is not None and fs.protocol != "file":
						return True
			else:
						return False


def _lowerCamelCase	(		_UpperCamelCase    , _UpperCamelCase    , _UpperCamelCase      ):

			'''simple docstring'''




			__lowerCAmelCase				    =			not is_remote_filesystem(lowerCamelCase__      )
			if is_local:
						# LocalFileSystem.mv does copy + rm, it is more efficient to simply move a local directory
						shutil.move(fs._strip_protocol(lowerCamelCase__      )    , fs._strip_protocol(lowerCamelCase__      )      )
			else:
						fs.mv(lowerCamelCase__    , lowerCamelCase__    , recursive=lowerCamelCase__      )


def _lowerCamelCase	(		):

			'''simple docstring'''




			if hasattr(fsspec.asyn    , "reset_lock"      ):
						# for future fsspec>2022.05.0
						fsspec.asyn.reset_lock()
			else:
						__lowerCAmelCase				    =			None
						__lowerCAmelCase				    =			None
						__lowerCAmelCase				    =			threading.Lock()






from abc import ABC, abstractmethod
from argparse import ArgumentParser




class     _SCREAMING_SNAKE_CASE     (      snake_case_						):



	@staticmethod
	@abstractmethod
	def     SCREAMING_SNAKE_CASE_(    lowercase )				->       int:
					raise NotImplementedError()



	@abstractmethod
	def     SCREAMING_SNAKE_CASE_(    self )				->       Union[str, Any]:
					raise NotImplementedError()


