def __init__(self, filesystem: FileSystem, path: str, mode: str = "rb"): self.filesystem = filesystem self.path = path self.mode = mode self._file = filesystem.open(self.path, mode={ "r": "rb", "w": "wb" }.get(mode, mode))
def __init__(self, filesystem: FileSystem, path: str, mode: str = "rb", encoding: Optional[str] = "utf-8"): self.filesystem = filesystem self.path = path self.mode = mode self.encoding = None if "b" in mode else encoding self._file = filesystem.open(self.path, mode={ "r": "rb", "w": "wb" }.get(mode, mode))