


"""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      __lowerCamelCase	(       a__					):

     '''simple docstring'''
     A_							:						List[Any]     =		'mock'


     def __init__(   self     ,					*__UpperCAmelCase     ,					__UpperCAmelCase     ,					**__UpperCAmelCase				)							->				int:
          super().__init__()
          _a     						=					LocalFileSystem(*__UpperCAmelCase     ,					**__UpperCAmelCase				)
          _a     						=					Path(__UpperCAmelCase				).resolve().as_posix() + '''/'''


     def 				_UpperCAmelCase   (   self     ,					__UpperCAmelCase     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)							->				str:
          _a     						=					posixpath.join(self.local_root_dir     ,					self._strip_protocol(__UpperCAmelCase				)				)
          return self._fs.mkdir(__UpperCAmelCase     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)


     def 				_UpperCAmelCase   (   self     ,					__UpperCAmelCase     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)							->				Tuple:
          _a     						=					posixpath.join(self.local_root_dir     ,					self._strip_protocol(__UpperCAmelCase				)				)
          return self._fs.makedirs(__UpperCAmelCase     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)


     def 				_UpperCAmelCase   (   self     ,					__UpperCAmelCase				)							->				Optional[Any]:
          _a     						=					posixpath.join(self.local_root_dir     ,					self._strip_protocol(__UpperCAmelCase				)				)
          return self._fs.rmdir(__UpperCAmelCase				)


     def 				_UpperCAmelCase   (   self     ,					__UpperCAmelCase     ,					__UpperCAmelCase=True     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)							->				Any:
          _a     						=					posixpath.join(self.local_root_dir     ,					self._strip_protocol(__UpperCAmelCase				)				)
          _a     						=					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 				_UpperCAmelCase   (   self     ,					__UpperCAmelCase     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)							->				int:
          _a     						=					posixpath.join(self.local_root_dir     ,					self._strip_protocol(__UpperCAmelCase				)				)
          _a     						=					dict(self._fs.info(__UpperCAmelCase     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)				)
          _a     						=					out['''name'''][len(self.local_root_dir				) :]
          return out


     def 				_UpperCAmelCase   (   self     ,					__UpperCAmelCase     ,					__UpperCAmelCase     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)							->				Any:
          _a     						=					posixpath.join(self.local_root_dir     ,					self._strip_protocol(__UpperCAmelCase				)				)
          _a     						=					posixpath.join(self.local_root_dir     ,					self._strip_protocol(__UpperCAmelCase				)				)
          return self._fs.cp_file(__UpperCAmelCase     ,					__UpperCAmelCase     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)


     def 				_UpperCAmelCase   (   self     ,					__UpperCAmelCase     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)							->				Optional[int]:
          _a     						=					posixpath.join(self.local_root_dir     ,					self._strip_protocol(__UpperCAmelCase				)				)
          return self._fs.rm_file(__UpperCAmelCase     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)


     def 				_UpperCAmelCase   (   self     ,					__UpperCAmelCase     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)							->				int:
          _a     						=					posixpath.join(self.local_root_dir     ,					self._strip_protocol(__UpperCAmelCase				)				)
          return self._fs.rm(__UpperCAmelCase     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)


     def 				_UpperCAmelCase   (   self     ,					__UpperCAmelCase     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)							->				List[str]:
          _a     						=					posixpath.join(self.local_root_dir     ,					self._strip_protocol(__UpperCAmelCase				)				)
          return self._fs._open(__UpperCAmelCase     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)


     def 				_UpperCAmelCase   (   self     ,					__UpperCAmelCase				)							->				Dict:
          _a     						=					posixpath.join(self.local_root_dir     ,					self._strip_protocol(__UpperCAmelCase				)				)
          return self._fs.created(__UpperCAmelCase				)


     def 				_UpperCAmelCase   (   self     ,					__UpperCAmelCase				)							->				Optional[Any]:
          _a     						=					posixpath.join(self.local_root_dir     ,					self._strip_protocol(__UpperCAmelCase				)				)
          return self._fs.modified(__UpperCAmelCase				)





     @classmethod
     def 				_UpperCAmelCase   (   cls     ,					__UpperCAmelCase				)							->				List[Any]:
          _a     						=					stringify_path(__UpperCAmelCase				)
          if path.startswith('''mock://'''				):
               _a     						=					path[7:]
          return path







class      __lowerCamelCase	(       a__					):

     '''simple docstring'''
     A_							:						Union[str, Any]     =		'tmp'
     A_							:						Optional[int]     =		None


     def __init__(   self     ,					*__UpperCAmelCase     ,					**__UpperCAmelCase				)							->				Any:
          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 				_UpperCAmelCase   (   cls     ,					__UpperCAmelCase				)							->				List[Any]:
          _a     						=					stringify_path(__UpperCAmelCase				)
          if path.startswith('''tmp://'''				):
               _a     						=					path[6:]
          return path







@pytest.fixture
def    A_ ( ):






     """simple docstring"""

     _a     						=					MockFileSystem
     _a     						=					TmpDirFileSystem
     yield
     del _fsspec_registry["mock"]
     del _fsspec_registry["tmp"]
@pytest.fixture
def    A_ ( _lowerCAmelCase  :       str,  _lowerCAmelCase  :       Any							):






     """simple docstring"""

     _a     						=					tmp_path_factory.mktemp('''mockfs'''							)
     return MockFileSystem(local_root_dir=_lowerCAmelCase,  auto_mkdir=_lowerCAmelCase							)

@pytest.fixture
def    A_ ( _lowerCAmelCase  :       Union[str, Any],  _lowerCAmelCase  :       Tuple							):






     """simple docstring"""

     _a     						=					tmp_path_factory.mktemp('''tmpfs'''							)
     with patch.object(_lowerCAmelCase,  '''tmp_dir''',  _lowerCAmelCase							):
          yield TmpDirFileSystem()



"""simple docstring"""






def    A_ ( _lowerCAmelCase  :       str							):






     """simple docstring"""

     return "".join(chr(ord(_lowerCAmelCase							) + 32							) if '''A''' <= char <= '''Z''' else char for char in word							)


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

   testmod()