Skip to content

Commit

Permalink
Add support for + modes to SSHFile (#51)
Browse files Browse the repository at this point in the history
* Implement io.IOBase.seekable method

* Add support for + modes to SSHFile
  • Loading branch information
mxmlnkn authored Oct 3, 2024
1 parent 5b29464 commit 34b52b2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sshfs/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def __init__(
self.fs = fs
self.loop = fs.loop

# TODO: support r+ / w+ / a+
if mode not in {"rb", "wb", "ab"}:
if "t" in mode or "b" not in mode:
raise ValueError(f"Unsupported file mode: {mode}")

self.path = path
Expand Down Expand Up @@ -79,13 +78,16 @@ async def _open_file(self):
_close = _mirror_method("close")

def readable(self):
return "r" in self.mode
return "r" in self.mode or "+" in self.mode

def seekable(self):
return "r" in self.mode or "w" in self.mode

def seekable(self):
return True

def writable(self):
return not self.readable()
return any(x in self.mode for x in ["a", "w", "+"])

def close(self):
if self._closed:
Expand Down

0 comments on commit 34b52b2

Please sign in to comment.