
"""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    _snake_case  (						_lowercase       ):
							SCREAMING_SNAKE_CASE		     =						'''mock'''






							def __init__(					self						:			List[str]						, *snake_case__						:			List[str]						, snake_case__						:			List[Any]						, **snake_case__						:			Optional[Any]    ):






												"""simple docstring"""



												super().__init__()
												__a:						List[Any]		    =					LocalFileSystem(*snake_case__						, **snake_case__    )
												__a:						Optional[int]		    =					Path(snake_case__    ).resolve().as_posix() + """/"""






							def 							__lowercase  (					self						:			Optional[Any]						, snake_case__						:			Tuple						, *snake_case__						:			Any						, **snake_case__						:			Union[str, Any]    ):






												"""simple docstring"""



												__a:						Optional[int]		    =					posixpath.join(self.local_root_dir						, self._strip_protocol(snake_case__    )    )
												return self._fs.mkdir(snake_case__						, *snake_case__						, **snake_case__    )






							def 							__lowercase  (					self						:			Union[str, Any]						, snake_case__						:			int						, *snake_case__						:			List[str]						, **snake_case__						:			str    ):






												"""simple docstring"""



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






							def 							__lowercase  (					self						:			int						, snake_case__						:			Tuple    ):






												"""simple docstring"""



												__a:						Any		    =					posixpath.join(self.local_root_dir						, self._strip_protocol(snake_case__    )    )
												return self._fs.rmdir(snake_case__    )






							def 							__lowercase  (					self						:			str						, snake_case__						:			List[Any]						, snake_case__						:			Any=True						, *snake_case__						:			Optional[int]						, **snake_case__						:			Dict    ):






												"""simple docstring"""



												__a:						Optional[int]		    =					posixpath.join(self.local_root_dir						, self._strip_protocol(snake_case__    )    )
												__a:						Optional[int]		    =					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 							__lowercase  (					self						:			int						, snake_case__						:			List[str]						, *snake_case__						:			str						, **snake_case__						:			Optional[Any]    ):






												"""simple docstring"""



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






							def 							__lowercase  (					self						:			List[str]						, snake_case__						:			Dict						, snake_case__						:			List[Any]						, *snake_case__						:			Union[str, Any]						, **snake_case__						:			List[Any]    ):






												"""simple docstring"""



												__a:						List[Any]		    =					posixpath.join(self.local_root_dir						, self._strip_protocol(snake_case__    )    )
												__a:						Any		    =					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 							__lowercase  (					self						:			Any						, snake_case__						:			str						, *snake_case__						:			str						, **snake_case__						:			List[Any]    ):






												"""simple docstring"""



												__a:						Dict		    =					posixpath.join(self.local_root_dir						, self._strip_protocol(snake_case__    )    )
												return self._fs.rm_file(snake_case__						, *snake_case__						, **snake_case__    )






							def 							__lowercase  (					self						:			Optional[Any]						, snake_case__						:			Optional[int]						, *snake_case__						:			Tuple						, **snake_case__						:			List[str]    ):






												"""simple docstring"""



												__a:						Union[str, Any]		    =					posixpath.join(self.local_root_dir						, self._strip_protocol(snake_case__    )    )
												return self._fs.rm(snake_case__						, *snake_case__						, **snake_case__    )






							def 							__lowercase  (					self						:			int						, snake_case__						:			Union[str, Any]						, *snake_case__						:			Tuple						, **snake_case__						:			Union[str, Any]    ):






												"""simple docstring"""



												__a:						str		    =					posixpath.join(self.local_root_dir						, self._strip_protocol(snake_case__    )    )
												return self._fs._open(snake_case__						, *snake_case__						, **snake_case__    )






							def 							__lowercase  (					self						:			int						, snake_case__						:			Optional[Any]    ):






												"""simple docstring"""



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






							def 							__lowercase  (					self						:			Optional[Any]						, snake_case__						:			Optional[int]    ):






												"""simple docstring"""



												__a:						str		    =					posixpath.join(self.local_root_dir						, self._strip_protocol(snake_case__    )    )
												return self._fs.modified(snake_case__    )






							@classmethod
							def 							__lowercase  (					cls						:			List[Any]						, snake_case__						:			Union[str, Any]    ):






												"""simple docstring"""



												__a:						Optional[int]		    =					stringify_path(snake_case__    )
												if path.startswith("""mock://"""    ):
																	__a:						Tuple		    =					path[7:]
												return path






class    _snake_case  (						_lowercase       ):
							SCREAMING_SNAKE_CASE		     =						'''tmp'''
							SCREAMING_SNAKE_CASE		     =						None






							def __init__(					self						:			Dict						, *snake_case__						:			Union[str, Any]						, **snake_case__						:			Tuple    ):






												"""simple docstring"""



												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 							__lowercase  (					cls						:			Tuple						, snake_case__						:			Dict    ):






												"""simple docstring"""



												__a:						int		    =					stringify_path(snake_case__    )
												if path.startswith("""tmp://"""    ):
																	__a:						Any		    =					path[6:]
												return path






@pytest.fixture
def     lowerCamelCase_    (	)     ->			str:


					'''simple docstring'''
					__a:						List[Any]		    =					MockFileSystem
					__a:						int		    =					TmpDirFileSystem
					yield
					del _fsspec_registry["mock"]
					del _fsspec_registry["tmp"]


@pytest.fixture
def     lowerCamelCase_    (	lowerCamelCase_	,				lowerCamelCase_ )     ->			int:


					'''simple docstring'''
					__a:						str		    =					tmp_path_factory.mktemp("""mockfs""" )
					return MockFileSystem(local_root_dir=lowerCamelCase_	,				auto_mkdir=lowerCamelCase_ )




@pytest.fixture
def     lowerCamelCase_    (	lowerCamelCase_	,				lowerCamelCase_ )     ->			Optional[Any]:


					'''simple docstring'''
					__a:						int		    =					tmp_path_factory.mktemp("""tmpfs""" )
					with patch.object(lowerCamelCase_	,				"""tmp_dir"""	,				lowerCamelCase_ ):
										yield TmpDirFileSystem()


"""simple docstring"""
lowercase		:						str =					{
    '0000': '0',
    '0001': '1',
    '0010': '2',
    '0011': '3',
    '0100': '4',
    '0101': '5',
    '0110': '6',
    '0111': '7',
    '1000': '8',
    '1001': '9',
    '1010': 'a',
    '1011': 'b',
    '1100': 'c',
    '1101': 'd',
    '1110': 'e',
    '1111': 'f',
}


def     lowerCamelCase_    (	lowerCamelCase_ )     ->			str:


					'''simple docstring'''
					__a:						Optional[int]		    =					str(lowerCamelCase_ ).strip()

					# Exceptions
					if not binary_str:
										raise ValueError("""Empty string was passed to the function""" )
					__a:						List[Any]		    =					binary_str[0] == """-"""
					__a:						List[str]		    =					binary_str[1:] if is_negative else binary_str
					if not all(char in """01""" for char in binary_str ):
										raise ValueError("""Non-binary value was passed to the function""" )

					__a:						Any		    =					(
					    """0""" * (4 * (divmod(len(lowerCamelCase_ )	,				4 )[0] + 1) - len(lowerCamelCase_ )) + binary_str
					)

					__a:						int		    =					[]
					for x in range(0	,				len(lowerCamelCase_ )	,				4 ):
										hexadecimal.append(BITS_TO_HEX[binary_str[x : x + 4]] )
					__a:						Tuple		    =					"""0x""" + """""".join(lowerCamelCase_ )

					return "-" + hexadecimal_str if is_negative else hexadecimal_str


if __name__ == "__main__":
			from doctest import testmod

			testmod()
