
'''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    A     (	SCREAMING_SNAKE_CASE__    ):
	snake_case__      :Union[str, Any]        =     '''mock'''





	def __init__(					self			:       Optional[Any]      ,							*__magic_name__			:       int      ,							__magic_name__			:       List[str]      ,							**__magic_name__			:       Tuple							):


				"""simple docstring"""

				super().__init__()
				lowerCAmelCase__								=							LocalFileSystem(*a_      ,							**a_							)
				lowerCAmelCase__								=							Path(a_							).resolve().as_posix() + "/"





	def 							__SCREAMING_SNAKE_CASE  (					self			:       int      ,							__magic_name__			:       List[Any]      ,							*__magic_name__			:       Dict      ,							**__magic_name__			:       Optional[Any]							):


				"""simple docstring"""

				lowerCAmelCase__								=							posixpath.join(self.local_root_dir      ,							self._strip_protocol(a_							)							)
				return self._fs.mkdir(a_      ,							*a_      ,							**a_							)





	def 							__SCREAMING_SNAKE_CASE  (					self			:       Optional[Any]      ,							__magic_name__			:       Union[str, Any]      ,							*__magic_name__			:       Any      ,							**__magic_name__			:       Optional[int]							):


				"""simple docstring"""

				lowerCAmelCase__								=							posixpath.join(self.local_root_dir      ,							self._strip_protocol(a_							)							)
				return self._fs.makedirs(a_      ,							*a_      ,							**a_							)





	def 							__SCREAMING_SNAKE_CASE  (					self			:       Dict      ,							__magic_name__			:       Tuple							):


				"""simple docstring"""

				lowerCAmelCase__								=							posixpath.join(self.local_root_dir      ,							self._strip_protocol(a_							)							)
				return self._fs.rmdir(a_							)





	def 							__SCREAMING_SNAKE_CASE  (					self			:       Tuple      ,							__magic_name__			:       str      ,							__magic_name__			:       Any=True      ,							*__magic_name__			:       Tuple      ,							**__magic_name__			:       int							):


				"""simple docstring"""

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


				"""simple docstring"""

				lowerCAmelCase__								=							posixpath.join(self.local_root_dir      ,							self._strip_protocol(a_							)							)
				lowerCAmelCase__								=							dict(self._fs.info(a_      ,							*a_      ,							**a_							)							)
				lowerCAmelCase__								=							out["name"][len(self.local_root_dir							) :]
				return out





	def 							__SCREAMING_SNAKE_CASE  (					self			:       Optional[int]      ,							__magic_name__			:       Dict      ,							__magic_name__			:       Optional[Any]      ,							*__magic_name__			:       Tuple      ,							**__magic_name__			:       Union[str, Any]							):


				"""simple docstring"""

				lowerCAmelCase__								=							posixpath.join(self.local_root_dir      ,							self._strip_protocol(a_							)							)
				lowerCAmelCase__								=							posixpath.join(self.local_root_dir      ,							self._strip_protocol(a_							)							)
				return self._fs.cp_file(a_      ,							a_      ,							*a_      ,							**a_							)





	def 							__SCREAMING_SNAKE_CASE  (					self			:       Optional[int]      ,							__magic_name__			:       str      ,							*__magic_name__			:       Any      ,							**__magic_name__			:       Optional[Any]							):


				"""simple docstring"""

				lowerCAmelCase__								=							posixpath.join(self.local_root_dir      ,							self._strip_protocol(a_							)							)
				return self._fs.rm_file(a_      ,							*a_      ,							**a_							)





	def 							__SCREAMING_SNAKE_CASE  (					self			:       Union[str, Any]      ,							__magic_name__			:       int      ,							*__magic_name__			:       Optional[Any]      ,							**__magic_name__			:       List[Any]							):


				"""simple docstring"""

				lowerCAmelCase__								=							posixpath.join(self.local_root_dir      ,							self._strip_protocol(a_							)							)
				return self._fs.rm(a_      ,							*a_      ,							**a_							)





	def 							__SCREAMING_SNAKE_CASE  (					self			:       Optional[Any]      ,							__magic_name__			:       Tuple      ,							*__magic_name__			:       int      ,							**__magic_name__			:       int							):


				"""simple docstring"""

				lowerCAmelCase__								=							posixpath.join(self.local_root_dir      ,							self._strip_protocol(a_							)							)
				return self._fs._open(a_      ,							*a_      ,							**a_							)





	def 							__SCREAMING_SNAKE_CASE  (					self			:       Union[str, Any]      ,							__magic_name__			:       Optional[Any]							):


				"""simple docstring"""

				lowerCAmelCase__								=							posixpath.join(self.local_root_dir      ,							self._strip_protocol(a_							)							)
				return self._fs.created(a_							)





	def 							__SCREAMING_SNAKE_CASE  (					self			:       str      ,							__magic_name__			:       List[Any]							):


				"""simple docstring"""

				lowerCAmelCase__								=							posixpath.join(self.local_root_dir      ,							self._strip_protocol(a_							)							)
				return self._fs.modified(a_							)







	@classmethod
	def 							__SCREAMING_SNAKE_CASE  (					cls			:       Tuple      ,							__magic_name__			:       Any							):


				"""simple docstring"""

				lowerCAmelCase__								=							stringify_path(a_							)
				if path.startswith("mock://"							):
							lowerCAmelCase__								=							path[7:]
				return path






class    A     (	SCREAMING_SNAKE_CASE__    ):
	snake_case__      :Tuple        =     '''tmp'''
	snake_case__      :Optional[int]        =     None





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


				"""simple docstring"""

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







	@classmethod
	def 							__SCREAMING_SNAKE_CASE  (					cls			:       Optional[int]      ,							__magic_name__			:       int							):


				"""simple docstring"""

				lowerCAmelCase__								=							stringify_path(a_							)
				if path.startswith("tmp://"							):
							lowerCAmelCase__								=							path[6:]
				return path







@pytest.fixture
def   A     (      )					->       Tuple:







			'''simple docstring'''



			lowerCAmelCase__								=							MockFileSystem
			lowerCAmelCase__								=							TmpDirFileSystem
			yield
			del _fsspec_registry["mock"]
			del _fsspec_registry["tmp"]







@pytest.fixture
def   A     (      UpperCamelCase_					:     Optional[int]						,	UpperCamelCase_					:     List[str]      )					->       int:







			'''simple docstring'''



			lowerCAmelCase__								=							tmp_path_factory.mktemp("mockfs"      )
			return MockFileSystem(local_root_dir=UpperCamelCase__						,	auto_mkdir=UpperCamelCase__      )







@pytest.fixture
def   A     (      UpperCamelCase_					:     Union[str, Any]						,	UpperCamelCase_					:     List[Any]      )					->       Optional[Any]:







			'''simple docstring'''



			lowerCAmelCase__								=							tmp_path_factory.mktemp("tmpfs"      )
			with patch.object(UpperCamelCase__						,	"tmp_dir"						,	UpperCamelCase__      ):
						yield TmpDirFileSystem()







'''simple docstring'''

from __future__ import annotations







def   A     (      UpperCamelCase_					:     int      )					->       list[int]:







			'''simple docstring'''



			assert (
			    isinstance(UpperCamelCase_						,	UpperCamelCase_      ) and mask > 0
			), F"""mask needs to be positive integer, your input {mask}"""
			lowerCAmelCase__								=							[]
			lowerCAmelCase__								=							mask

			while submask:
						all_submasks.append(UpperCamelCase_      )
						lowerCAmelCase__								=							(submask - 1) & mask

			return all_submasks


if __name__ == "__main__":
		import doctest

		doctest.testmod()





