




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 				__snake_case     (_a						):
				lowerCAmelCase__			=   "mock"



				def __init__(					self					:						Union[str, Any]						,		*_UpperCAmelCase					:						Union[str, Any]						,		_UpperCAmelCase					:						Optional[int]						,		**_UpperCAmelCase					:						List[str]					)     ->			Optional[int]:





								'''simple docstring'''




								super().__init__()
								_lowerCAmelCase			:			Tuple        =					LocalFileSystem(*_UpperCAmelCase						,		**_UpperCAmelCase					)
								_lowerCAmelCase			:			List[str]        =					Path(_UpperCAmelCase					).resolve().as_posix() + """/"""



				def 					SCREAMING_SNAKE_CASE				(					self					:						Dict						,		_UpperCAmelCase					:						Optional[int]						,		*_UpperCAmelCase					:						Dict						,		**_UpperCAmelCase					:						int					)     ->			int:





								'''simple docstring'''




								_lowerCAmelCase			:			str        =					posixpath.join(self.local_root_dir						,		self._strip_protocol(_UpperCAmelCase					)					)
								return self._fs.mkdir(_UpperCAmelCase						,		*_UpperCAmelCase						,		**_UpperCAmelCase					)



				def 					SCREAMING_SNAKE_CASE				(					self					:						int						,		_UpperCAmelCase					:						Optional[int]						,		*_UpperCAmelCase					:						Optional[Any]						,		**_UpperCAmelCase					:						Union[str, Any]					)     ->			Tuple:





								'''simple docstring'''




								_lowerCAmelCase			:			List[str]        =					posixpath.join(self.local_root_dir						,		self._strip_protocol(_UpperCAmelCase					)					)
								return self._fs.makedirs(_UpperCAmelCase						,		*_UpperCAmelCase						,		**_UpperCAmelCase					)



				def 					SCREAMING_SNAKE_CASE				(					self					:						str						,		_UpperCAmelCase					:						str					)     ->			Any:





								'''simple docstring'''




								_lowerCAmelCase			:			Dict        =					posixpath.join(self.local_root_dir						,		self._strip_protocol(_UpperCAmelCase					)					)
								return self._fs.rmdir(_UpperCAmelCase					)



				def 					SCREAMING_SNAKE_CASE				(					self					:						Union[str, Any]						,		_UpperCAmelCase					:						str						,		_UpperCAmelCase					:						List[Any]=True						,		*_UpperCAmelCase					:						Optional[int]						,		**_UpperCAmelCase					:						Tuple					)     ->			Optional[Any]:





								'''simple docstring'''




								_lowerCAmelCase			:			Union[str, Any]        =					posixpath.join(self.local_root_dir						,		self._strip_protocol(_UpperCAmelCase					)					)
								_lowerCAmelCase			:			str        =					self._fs.ls(_UpperCAmelCase						,		detail=_UpperCAmelCase						,		*_UpperCAmelCase						,		**_UpperCAmelCase					)
								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 					SCREAMING_SNAKE_CASE				(					self					:						List[Any]						,		_UpperCAmelCase					:						Any						,		*_UpperCAmelCase					:						List[str]						,		**_UpperCAmelCase					:						Optional[int]					)     ->			Union[str, Any]:





								'''simple docstring'''




								_lowerCAmelCase			:			int        =					posixpath.join(self.local_root_dir						,		self._strip_protocol(_UpperCAmelCase					)					)
								_lowerCAmelCase			:			Dict        =					dict(self._fs.info(_UpperCAmelCase						,		*_UpperCAmelCase						,		**_UpperCAmelCase					)					)
								_lowerCAmelCase			:			Union[str, Any]        =					out["""name"""][len(self.local_root_dir					) :]
								return out



				def 					SCREAMING_SNAKE_CASE				(					self					:						Optional[Any]						,		_UpperCAmelCase					:						Dict						,		_UpperCAmelCase					:						List[str]						,		*_UpperCAmelCase					:						Optional[Any]						,		**_UpperCAmelCase					:						List[str]					)     ->			str:





								'''simple docstring'''




								_lowerCAmelCase			:			Tuple        =					posixpath.join(self.local_root_dir						,		self._strip_protocol(_UpperCAmelCase					)					)
								_lowerCAmelCase			:			Union[str, Any]        =					posixpath.join(self.local_root_dir						,		self._strip_protocol(_UpperCAmelCase					)					)
								return self._fs.cp_file(_UpperCAmelCase						,		_UpperCAmelCase						,		*_UpperCAmelCase						,		**_UpperCAmelCase					)



				def 					SCREAMING_SNAKE_CASE				(					self					:						Dict						,		_UpperCAmelCase					:						Any						,		*_UpperCAmelCase					:						int						,		**_UpperCAmelCase					:						List[str]					)     ->			Optional[Any]:





								'''simple docstring'''




								_lowerCAmelCase			:			Any        =					posixpath.join(self.local_root_dir						,		self._strip_protocol(_UpperCAmelCase					)					)
								return self._fs.rm_file(_UpperCAmelCase						,		*_UpperCAmelCase						,		**_UpperCAmelCase					)



				def 					SCREAMING_SNAKE_CASE				(					self					:						Optional[Any]						,		_UpperCAmelCase					:						Optional[Any]						,		*_UpperCAmelCase					:						str						,		**_UpperCAmelCase					:						List[Any]					)     ->			Tuple:





								'''simple docstring'''




								_lowerCAmelCase			:			Optional[Any]        =					posixpath.join(self.local_root_dir						,		self._strip_protocol(_UpperCAmelCase					)					)
								return self._fs.rm(_UpperCAmelCase						,		*_UpperCAmelCase						,		**_UpperCAmelCase					)



				def 					SCREAMING_SNAKE_CASE				(					self					:						Optional[int]						,		_UpperCAmelCase					:						Union[str, Any]						,		*_UpperCAmelCase					:						Dict						,		**_UpperCAmelCase					:						Union[str, Any]					)     ->			Any:





								'''simple docstring'''




								_lowerCAmelCase			:			Union[str, Any]        =					posixpath.join(self.local_root_dir						,		self._strip_protocol(_UpperCAmelCase					)					)
								return self._fs._open(_UpperCAmelCase						,		*_UpperCAmelCase						,		**_UpperCAmelCase					)



				def 					SCREAMING_SNAKE_CASE				(					self					:						Dict						,		_UpperCAmelCase					:						Tuple					)     ->			Any:





								'''simple docstring'''




								_lowerCAmelCase			:			List[Any]        =					posixpath.join(self.local_root_dir						,		self._strip_protocol(_UpperCAmelCase					)					)
								return self._fs.created(_UpperCAmelCase					)



				def 					SCREAMING_SNAKE_CASE				(					self					:						Any						,		_UpperCAmelCase					:						Dict					)     ->			Dict:





								'''simple docstring'''




								_lowerCAmelCase			:			Optional[int]        =					posixpath.join(self.local_root_dir						,		self._strip_protocol(_UpperCAmelCase					)					)
								return self._fs.modified(_UpperCAmelCase					)



				@classmethod
				def 					SCREAMING_SNAKE_CASE				(					cls					:						List[Any]						,		_UpperCAmelCase					:						Tuple					)     ->			str:





								'''simple docstring'''




								_lowerCAmelCase			:			Any        =					stringify_path(_UpperCAmelCase					)
								if path.startswith("""mock://"""					):
												_lowerCAmelCase			:			Union[str, Any]        =					path[7:]
								return path






class 				__snake_case     (_a						):
				lowerCAmelCase__			=   "tmp"
				lowerCAmelCase__			=   None



				def __init__(					self					:						Optional[Any]						,		*_UpperCAmelCase					:						Tuple						,		**_UpperCAmelCase					:						Tuple					)     ->			List[Any]:





								'''simple docstring'''




								assert self.tmp_dir is not None, "TmpDirFileSystem.tmp_dir is not set"
								super().__init__(*_UpperCAmelCase						,		**_UpperCAmelCase						,		local_root_dir=self.tmp_dir						,		auto_mkdir=_UpperCAmelCase					)



				@classmethod
				def 					SCREAMING_SNAKE_CASE				(					cls					:						int						,		_UpperCAmelCase					:						Tuple					)     ->			Dict:





								'''simple docstring'''




								_lowerCAmelCase			:			int        =					stringify_path(_UpperCAmelCase					)
								if path.startswith("""tmp://"""					):
												_lowerCAmelCase			:			str        =					path[6:]
								return path






@pytest.fixture
def 							_UpperCAmelCase     ():
				'''simple docstring'''
				_lowerCAmelCase			:			str        =					MockFileSystem
				_lowerCAmelCase			:			Any        =					TmpDirFileSystem
				yield
				del _fsspec_registry["mock"]
				del _fsspec_registry["tmp"]




@pytest.fixture
def 							_UpperCAmelCase     (UpperCamelCase_       :       Dict					,			UpperCamelCase_       :       List[Any]				):
				'''simple docstring'''
				_lowerCAmelCase			:			int        =					tmp_path_factory.mktemp("""mockfs"""				)
				return MockFileSystem(local_root_dir=UpperCamelCase_					,			auto_mkdir=UpperCamelCase_				)





@pytest.fixture
def 							_UpperCAmelCase     (UpperCamelCase_       :       Optional[int]					,			UpperCamelCase_       :       Union[str, Any]				):
				'''simple docstring'''
				_lowerCAmelCase			:			Any        =					tmp_path_factory.mktemp("""tmpfs"""				)
				with patch.object(UpperCamelCase_					,			"""tmp_dir"""					,			UpperCamelCase_				):
								yield TmpDirFileSystem()


def 					snake_case						(__lowercase						)       ->       int:

						'''simple docstring'''



						if not isinstance(__lowercase					,			__lowercase						) or number < 0:
												raise ValueError("Input must be a non-negative integer"						)

						_snake_case						:     List[Any]				=    number & ~(number - 1)
						_snake_case						:     Union[str, Any]				=    0
						while intermediate:
												intermediate >>= 1
												index += 1
						return index - 1


if __name__ == "__main__":
				import doctest

				doctest.testmod(verbose=True)