Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions python/pyarrow/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class S3FSWrapper(DaskFileSystem):

@implements(FileSystem.isdir)
def isdir(self, path):
path = _stringify_path(path)
path = _sanitize_s3(_stringify_path(path))
try:
contents = self.fs.ls(path)
if len(contents) == 1 and contents[0] == path:
Expand All @@ -331,7 +331,7 @@ def isdir(self, path):

@implements(FileSystem.isfile)
def isfile(self, path):
path = _stringify_path(path)
path = _sanitize_s3(_stringify_path(path))
try:
contents = self.fs.ls(path)
return len(contents) == 1 and contents[0] == path
Expand All @@ -345,7 +345,7 @@ def walk(self, path, refresh=False):
Generator version of what is in s3fs, which yields a flattened list of
files
"""
path = _stringify_path(path).replace('s3://', '')
path = _sanitize_s3(_stringify_path(path))
directories = set()
files = set()

Expand All @@ -371,6 +371,13 @@ def walk(self, path, refresh=False):
yield tup


def _sanitize_s3(path):
if path.startswith('s3://'):
return path.replace('s3://', '')
else:
return path


def _ensure_filesystem(fs):
fs_type = type(fs)

Expand Down