



'''simple docstring'''






import posixpath
from pathlib import Path
from unittest.mock import patch

import pytest
from fsspec.implementations.local import AbstractFileSystem, LocalFileSystem, stringify_path
from fsspec.registry import _registry as _fsspec_registry

class     SCREAMING_SNAKE_CASE(							A__      ):







	"""simple docstring"""






	lowerCamelCase__      			=	"""mock"""







	def __init__(						self      :					Tuple		,      *__snake_case      :					List[str]		,      __snake_case      :					List[str]		,      **__snake_case      :					List[str]		)      ->		List[str]:
								super().__init__()
								UpperCAmelCase			:	int										=		LocalFileSystem(*__snake_case		,      **__snake_case		)
								UpperCAmelCase			:	Optional[Any]										=		Path(__snake_case		).resolve().as_posix() + '''/'''







	def 					A     (						self      :					str		,      __snake_case      :					List[str]		,      *__snake_case      :					str		,      **__snake_case      :					Union[str, Any]		)      ->		List[Any]:
								UpperCAmelCase			:	Tuple										=		posixpath.join(self.local_root_dir		,      self._strip_protocol(__snake_case		)		)
								return self._fs.mkdir(__snake_case		,      *__snake_case		,      **__snake_case		)







	def 					A     (						self      :					Any		,      __snake_case      :					Any		,      *__snake_case      :					Union[str, Any]		,      **__snake_case      :					str		)      ->		Tuple:
								UpperCAmelCase			:	Dict										=		posixpath.join(self.local_root_dir		,      self._strip_protocol(__snake_case		)		)
								return self._fs.makedirs(__snake_case		,      *__snake_case		,      **__snake_case		)







	def 					A     (						self      :					Tuple		,      __snake_case      :					str		)      ->		Dict:
								UpperCAmelCase			:	int										=		posixpath.join(self.local_root_dir		,      self._strip_protocol(__snake_case		)		)
								return self._fs.rmdir(__snake_case		)







	def 					A     (						self      :					Any		,      __snake_case      :					Tuple		,      __snake_case      :					Optional[int]=True		,      *__snake_case      :					List[str]		,      **__snake_case      :					Tuple		)      ->		Optional[Any]:
								UpperCAmelCase			:	Any										=		posixpath.join(self.local_root_dir		,      self._strip_protocol(__snake_case		)		)
								UpperCAmelCase			:	Union[str, Any]										=		self._fs.ls(__snake_case		,      detail=__snake_case		,      *__snake_case		,      **__snake_case		)
								if detail:
															return [{**info, "name": info["name"][len(self.local_root_dir		) :]} for info in out]
								else:
															return [name[len(self.local_root_dir		) :] for name in out]







	def 					A     (						self      :					List[str]		,      __snake_case      :					str		,      *__snake_case      :					Union[str, Any]		,      **__snake_case      :					Optional[Any]		)      ->		Any:
								UpperCAmelCase			:	Optional[int]										=		posixpath.join(self.local_root_dir		,      self._strip_protocol(__snake_case		)		)
								UpperCAmelCase			:	Any										=		dict(self._fs.info(__snake_case		,      *__snake_case		,      **__snake_case		)		)
								UpperCAmelCase			:	int										=		out['''name'''][len(self.local_root_dir		) :]
								return out







	def 					A     (						self      :					int		,      __snake_case      :					int		,      __snake_case      :					Optional[int]		,      *__snake_case      :					Optional[int]		,      **__snake_case      :					Any		)      ->		int:
								UpperCAmelCase			:	str										=		posixpath.join(self.local_root_dir		,      self._strip_protocol(__snake_case		)		)
								UpperCAmelCase			:	Optional[int]										=		posixpath.join(self.local_root_dir		,      self._strip_protocol(__snake_case		)		)
								return self._fs.cp_file(__snake_case		,      __snake_case		,      *__snake_case		,      **__snake_case		)







	def 					A     (						self      :					Optional[int]		,      __snake_case      :					Union[str, Any]		,      *__snake_case      :					List[Any]		,      **__snake_case      :					Optional[Any]		)      ->		Optional[Any]:
								UpperCAmelCase			:	Union[str, Any]										=		posixpath.join(self.local_root_dir		,      self._strip_protocol(__snake_case		)		)
								return self._fs.rm_file(__snake_case		,      *__snake_case		,      **__snake_case		)







	def 					A     (						self      :					List[str]		,      __snake_case      :					Tuple		,      *__snake_case      :					Optional[int]		,      **__snake_case      :					Tuple		)      ->		List[Any]:
								UpperCAmelCase			:	str										=		posixpath.join(self.local_root_dir		,      self._strip_protocol(__snake_case		)		)
								return self._fs.rm(__snake_case		,      *__snake_case		,      **__snake_case		)







	def 					A     (						self      :					Optional[Any]		,      __snake_case      :					Tuple		,      *__snake_case      :					Optional[Any]		,      **__snake_case      :					List[str]		)      ->		Dict:
								UpperCAmelCase			:	int										=		posixpath.join(self.local_root_dir		,      self._strip_protocol(__snake_case		)		)
								return self._fs._open(__snake_case		,      *__snake_case		,      **__snake_case		)







	def 					A     (						self      :					int		,      __snake_case      :					Dict		)      ->		Tuple:
								UpperCAmelCase			:	str										=		posixpath.join(self.local_root_dir		,      self._strip_protocol(__snake_case		)		)
								return self._fs.created(__snake_case		)







	def 					A     (						self      :					int		,      __snake_case      :					Optional[int]		)      ->		Dict:
								UpperCAmelCase			:	Tuple										=		posixpath.join(self.local_root_dir		,      self._strip_protocol(__snake_case		)		)
								return self._fs.modified(__snake_case		)







	@classmethod
	def 					A     (						cls      :					Optional[Any]		,      __snake_case      :					List[str]		)      ->		Optional[Any]:
								UpperCAmelCase			:	Tuple										=		stringify_path(__snake_case		)
								if path.startswith('''mock://'''		):
															UpperCAmelCase			:	Tuple										=		path[7:]
								return path

class     SCREAMING_SNAKE_CASE(							A__      ):







	"""simple docstring"""






	lowerCamelCase__      			=	"""tmp"""
	lowerCamelCase__      			=	None







	def __init__(						self      :					Any		,      *__snake_case      :					Tuple		,      **__snake_case      :					Optional[Any]		)      ->		Tuple:
								assert self.tmp_dir is not None, "TmpDirFileSystem.tmp_dir is not set"
								super().__init__(*__snake_case		,      **__snake_case		,      local_root_dir=self.tmp_dir		,      auto_mkdir=__snake_case		)







	@classmethod
	def 					A     (						cls      :					Any		,      __snake_case      :					Optional[int]		)      ->		Dict:
								UpperCAmelCase			:	List[str]										=		stringify_path(__snake_case		)
								if path.startswith('''tmp://'''		):
															UpperCAmelCase			:	Optional[int]										=		path[6:]
								return path


@pytest.fixture
def 			snake_case_					( )				->       Any:
							UpperCAmelCase			:	Union[str, Any]										=		MockFileSystem
							UpperCAmelCase			:	int										=		TmpDirFileSystem
							yield
							del _fsspec_registry["mock"]
							del _fsspec_registry["tmp"]


@pytest.fixture
def 			snake_case_					( _lowerCAmelCase  :						Optional[Any]       ,				_lowerCAmelCase  :						Optional[int]  )				->       Optional[int]:
							UpperCAmelCase			:	Dict										=		tmp_path_factory.mktemp('''mockfs'''  )
							return MockFileSystem(local_root_dir=_lowerCAmelCase       ,				auto_mkdir=_lowerCAmelCase  )




@pytest.fixture
def 			snake_case_					( _lowerCAmelCase  :						int       ,				_lowerCAmelCase  :						Optional[int]  )				->       Optional[Any]:
							UpperCAmelCase			:	Tuple										=		tmp_path_factory.mktemp('''tmpfs'''  )
							with patch.object(_lowerCAmelCase       ,				'''tmp_dir'''       ,				_lowerCAmelCase  ):
														yield TmpDirFileSystem()










'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


UpperCamelCase__:       Tuple							     =      {
    "configuration_splinter": ["SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP", "SplinterConfig"],
    "tokenization_splinter": ["SplinterTokenizer"],
}

try:
						if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase__:       Optional[Any]							     =      ["SplinterTokenizerFast"]

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase__:       Any							     =      [
						    "SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST",
						    "SplinterForQuestionAnswering",
						    "SplinterForPreTraining",
						    "SplinterLayer",
						    "SplinterModel",
						    "SplinterPreTrainedModel",
						]


if TYPE_CHECKING:
						from .configuration_splinter import SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP, SplinterConfig
						from .tokenization_splinter import SplinterTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_splinter_fast import SplinterTokenizerFast

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_splinter import (
												    SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST,
												    SplinterForPreTraining,
												    SplinterForQuestionAnswering,
												    SplinterLayer,
												    SplinterModel,
												    SplinterPreTrainedModel,
												)


else:
						import sys

						UpperCamelCase__:       Dict							     =      _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





