Skip to content

Commit

Permalink
Add PrefixFileSystem behaviour on open() docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
lucmos committed Oct 1, 2021
1 parent c7f763f commit 8d5e117
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions fsspec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,12 +812,12 @@ def put(self, lpath, rpath, recursive=False, callback=_DEFAULT_CALLBACK, **kwarg
self.put_file(lpath, rpath, **kwargs)

def head(self, path, size=1024):
""" Get the first ``size`` bytes from file """
"""Get the first ``size`` bytes from file"""
with self.open(path, "rb") as f:
return f.read(size)

def tail(self, path, size=1024):
""" Get the last ``size`` bytes from file """
"""Get the last ``size`` bytes from file"""
with self.open(path, "rb") as f:
f.seek(max(-size, -f.size), 2)
return f.read()
Expand Down Expand Up @@ -879,7 +879,7 @@ def expand_path(self, path, recursive=False, maxdepth=None):
return list(sorted(out))

def mv(self, path1, path2, recursive=False, maxdepth=None, **kwargs):
""" Move file(s) from one location to another """
"""Move file(s) from one location to another"""
self.copy(path1, path2, recursive=recursive, maxdepth=maxdepth)
self.rm(path1, recursive=recursive)

Expand Down Expand Up @@ -944,6 +944,10 @@ def open(self, path, mode="rb", block_size=None, cache_options=None, **kwargs):
"""
Return a file-like object from the filesystem
The file-like object returned ignores an eventual PrefixFileSystem:
- the ``.path`` attribute is always an absolute path
- the``.fs`` attribute, if present, would be the wrapped file-system
The resultant instance must function correctly in a context ``with``
block.
Expand Down Expand Up @@ -1341,14 +1345,14 @@ def discard(self):
"""Throw away temporary file"""

def info(self):
""" File information about this path """
"""File information about this path"""
if "r" in self.mode:
return self.details
else:
raise ValueError("Info not available while writing")

def tell(self):
""" Current file location """
"""Current file location"""
return self.loc

def seek(self, loc, whence=0):
Expand Down Expand Up @@ -1455,7 +1459,7 @@ def _upload_chunk(self, final=False):
# may not yet have been initialized, may need to call _initialize_upload

def _initiate_upload(self):
""" Create remote file/upload """
"""Create remote file/upload"""
pass

def _fetch_range(self, start, end):
Expand Down

0 comments on commit 8d5e117

Please sign in to comment.