

'''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 		UpperCamelCase_		(					A__   ):





						"""simple docstring"""




						UpperCAmelCase__	:       Union[str, Any]         =     '''mock'''
						def __init__( self				:					str	,				*_lowerCamelCase				:					List[str]	,				_lowerCamelCase				:					Tuple	,				**_lowerCamelCase				:					str  )							->					int:
										super().__init__()
										__magic_name__	  = LocalFileSystem(*_lowerCAmelCase	,				**_lowerCAmelCase  )
										__magic_name__	  = Path(_lowerCAmelCase  ).resolve().as_posix() + "/"
						def 					__A					( self				:					int	,				_lowerCamelCase				:					str	,				*_lowerCamelCase				:					Dict	,				**_lowerCamelCase				:					Optional[Any]  )							->					Union[str, Any]:
										__magic_name__	  = posixpath.join(self.local_root_dir	,				self._strip_protocol(_lowerCAmelCase  )  )
										return self._fs.mkdir(_lowerCAmelCase	,				*_lowerCAmelCase	,				**_lowerCAmelCase  )
						def 					__A					( self				:					List[Any]	,				_lowerCamelCase				:					List[str]	,				*_lowerCamelCase				:					Optional[Any]	,				**_lowerCamelCase				:					str  )							->					List[str]:
										__magic_name__	  = posixpath.join(self.local_root_dir	,				self._strip_protocol(_lowerCAmelCase  )  )
										return self._fs.makedirs(_lowerCAmelCase	,				*_lowerCAmelCase	,				**_lowerCAmelCase  )
						def 					__A					( self				:					List[str]	,				_lowerCamelCase				:					Dict  )							->					Any:
										__magic_name__	  = posixpath.join(self.local_root_dir	,				self._strip_protocol(_lowerCAmelCase  )  )
										return self._fs.rmdir(_lowerCAmelCase  )
						def 					__A					( self				:					Dict	,				_lowerCamelCase				:					List[str]	,				_lowerCamelCase				:					Optional[Any]=True	,				*_lowerCamelCase				:					List[str]	,				**_lowerCamelCase				:					str  )							->					List[str]:
										__magic_name__	  = posixpath.join(self.local_root_dir	,				self._strip_protocol(_lowerCAmelCase  )  )
										__magic_name__	  = self._fs.ls(_lowerCAmelCase	,				detail=_lowerCAmelCase	,				*_lowerCAmelCase	,				**_lowerCAmelCase  )
										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				:					Dict	,				_lowerCamelCase				:					List[Any]	,				*_lowerCamelCase				:					Dict	,				**_lowerCamelCase				:					Any  )							->					List[Any]:
										__magic_name__	  = posixpath.join(self.local_root_dir	,				self._strip_protocol(_lowerCAmelCase  )  )
										__magic_name__	  = dict(self._fs.info(_lowerCAmelCase	,				*_lowerCAmelCase	,				**_lowerCAmelCase  )  )
										__magic_name__	  = out["name"][len(self.local_root_dir  ) :]
										return out
						def 					__A					( self				:					List[str]	,				_lowerCamelCase				:					List[str]	,				_lowerCamelCase				:					Tuple	,				*_lowerCamelCase				:					str	,				**_lowerCamelCase				:					List[str]  )							->					Any:
										__magic_name__	  = posixpath.join(self.local_root_dir	,				self._strip_protocol(_lowerCAmelCase  )  )
										__magic_name__	  = posixpath.join(self.local_root_dir	,				self._strip_protocol(_lowerCAmelCase  )  )
										return self._fs.cp_file(_lowerCAmelCase	,				_lowerCAmelCase	,				*_lowerCAmelCase	,				**_lowerCAmelCase  )
						def 					__A					( self				:					List[str]	,				_lowerCamelCase				:					Any	,				*_lowerCamelCase				:					Dict	,				**_lowerCamelCase				:					List[Any]  )							->					List[str]:
										__magic_name__	  = posixpath.join(self.local_root_dir	,				self._strip_protocol(_lowerCAmelCase  )  )
										return self._fs.rm_file(_lowerCAmelCase	,				*_lowerCAmelCase	,				**_lowerCAmelCase  )
						def 					__A					( self				:					Any	,				_lowerCamelCase				:					Dict	,				*_lowerCamelCase				:					Optional[int]	,				**_lowerCamelCase				:					List[str]  )							->					List[Any]:
										__magic_name__	  = posixpath.join(self.local_root_dir	,				self._strip_protocol(_lowerCAmelCase  )  )
										return self._fs.rm(_lowerCAmelCase	,				*_lowerCAmelCase	,				**_lowerCAmelCase  )
						def 					__A					( self				:					Tuple	,				_lowerCamelCase				:					Dict	,				*_lowerCamelCase				:					Optional[Any]	,				**_lowerCamelCase				:					Dict  )							->					int:
										__magic_name__	  = posixpath.join(self.local_root_dir	,				self._strip_protocol(_lowerCAmelCase  )  )
										return self._fs._open(_lowerCAmelCase	,				*_lowerCAmelCase	,				**_lowerCAmelCase  )
						def 					__A					( self				:					Union[str, Any]	,				_lowerCamelCase				:					int  )							->					List[Any]:
										__magic_name__	  = posixpath.join(self.local_root_dir	,				self._strip_protocol(_lowerCAmelCase  )  )
										return self._fs.created(_lowerCAmelCase  )
						def 					__A					( self				:					Tuple	,				_lowerCamelCase				:					Any  )							->					Dict:
										__magic_name__	  = posixpath.join(self.local_root_dir	,				self._strip_protocol(_lowerCAmelCase  )  )
										return self._fs.modified(_lowerCAmelCase  )

						@classmethod
						def 					__A					( cls				:					List[str]	,				_lowerCamelCase				:					Dict  )							->					List[Any]:
										__magic_name__	  = stringify_path(_lowerCAmelCase  )
										if path.startswith("mock://"  ):
														__magic_name__	  = path[7:]
										return path






class 		UpperCamelCase_		(					A__   ):





						"""simple docstring"""




						UpperCAmelCase__	:       Optional[Any]         =     '''tmp'''
						UpperCAmelCase__	:       str         =     None
						def __init__( self				:					List[str]	,				*_lowerCamelCase				:					Union[str, Any]	,				**_lowerCamelCase				:					str  )							->					Dict:
										assert self.tmp_dir is not None, "TmpDirFileSystem.tmp_dir is not set"
										super().__init__(*_lowerCAmelCase	,				**_lowerCAmelCase	,				local_root_dir=self.tmp_dir	,				auto_mkdir=_lowerCAmelCase  )

						@classmethod
						def 					__A					( cls				:					Dict	,				_lowerCamelCase				:					Dict  )							->					Optional[Any]:
										__magic_name__	  = stringify_path(_lowerCAmelCase  )
										if path.startswith("tmp://"  ):
														__magic_name__	  = path[6:]
										return path





@pytest.fixture
def      __snake_case       (       ):
				'''simple docstring'''




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




@pytest.fixture
def      __snake_case       (       lowerCamelCase_ :				Optional[int]	,  lowerCamelCase_ :				Any						):
				'''simple docstring'''




				__magic_name__	  = tmp_path_factory.mktemp("mockfs"						)
				return MockFileSystem(local_root_dir=lowerCamelCase_	,  auto_mkdir=lowerCamelCase_						)




@pytest.fixture
def      __snake_case       (       lowerCamelCase_ :				Tuple	,  lowerCamelCase_ :				Union[str, Any]						):
				'''simple docstring'''




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







'''simple docstring'''
import os
import sys
import time

from . import transposition_cipher as trans_cipher




def      __snake_case       (       ):
				'''simple docstring'''




				__magic_name__	  = "Prehistoric Men.txt"
				__magic_name__	  = "Output.txt"
				__magic_name__	  = int(input("Enter key: "						)						)
				__magic_name__	  = input("Encrypt/Decrypt [e/d]: "						)

				if not os.path.exists(lowerCamelCase_						):
								print(F'File {input_file} does not exist. Quitting...'						)
								sys.exit()
				if os.path.exists(lowerCamelCase_						):
								print(F'Overwrite {output_file}? [y/n]'						)
								__magic_name__	  = input("> "						)
								if not response.lower().startswith("y"						):
												sys.exit()

				__magic_name__	  = time.time()
				if mode.lower().startswith("e"						):
								with open(lowerCamelCase_						) as f:
												__magic_name__	  = f.read()
								__magic_name__	  = trans_cipher.encrypt_message(lowerCamelCase_	,  lowerCamelCase_						)
				elif mode.lower().startswith("d"						):
								with open(lowerCamelCase_						) as f:
												__magic_name__	  = f.read()
								__magic_name__	  = trans_cipher.decrypt_message(lowerCamelCase_	,  lowerCamelCase_						)

				with open(lowerCamelCase_	,  "w"						) as output_obj:
								output_obj.write(lowerCamelCase_						)

				__magic_name__	  = round(time.time() - start_time	,  2						)
				print(("Done (", total_time, "seconds )")						)


if __name__ == "__main__":
						main()



