import pathlib from .encode import encode from .decode import decode class file(encode): def __init__(self, path: pathlib.Path, content: bytes) -> None: self.__path = path self.__content = content @property def path(self) -> pathlib.Path: return self.__path @property def content(self) -> bytes: return self.__content @property def path_name(self) -> str: return str(self.__path) def encode(self) -> object: encoded_path = self._encode_str(self.path_name) encoded_content = self._encode_bytes(self.content) return encoded_file(encoded_path, encoded_content) class encoded_file(decode): def __init__(self, path: str, content: str) -> None: self.__path = path self.__content = content @property def encoded_path(self) -> str: return self.__path @property def encoded_content(self) -> str: return self.__content def decode(self) -> file: content = self._decode_bytes(self.encoded_content) path_name = self._decode_str(self.encoded_path) path = pathlib.Path(path_name) return file(path, content)