Skip to content

Commit

Permalink
add the make_path_posix
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankEssenberger committed Feb 25, 2025
1 parent a8baa5a commit 2f11c69
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions fsspec/implementations/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ def ls(self, path, detail=False, **kwargs):
with os.scandir(path) as it:
for f in it:
try:
# Only get the info if requested since it is a bit expensive
info = self.info(f) if detail else f.path
# Only get the info if requested since it is a bit expensive (the stat call inside)
# The strip_protocol is also used in info() and calls make_path_posix to always return posix paths
info = self.info(f) if detail else self._strip_protocol(f.path)
infos.append(info)
except FileNotFoundError:
pass
Expand Down
4 changes: 2 additions & 2 deletions fsspec/implementations/tests/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def test_directories(tmpdir):
def test_ls_on_file(tmpdir):
tmpdir = make_path_posix(str(tmpdir))
fs = LocalFileSystem()
resource = str(Path(tmpdir) / "a.json")
resource = tmpdir + "/a.json"
fs.touch(resource)
assert fs.exists(resource)
assert fs.ls(tmpdir) == fs.ls(resource)
Expand All @@ -408,7 +408,7 @@ def test_ls_on_file(tmpdir):
def test_ls_on_files(tmpdir):
tmpdir = make_path_posix(str(tmpdir))
fs = LocalFileSystem()
resources = [str(Path(tmpdir)/f) for f in ["file_1.json", "file_2.json"]]
resources = [f"{tmpdir}/{file}" for file in ["file_1.json", "file_2.json"]]
for r in resources:
fs.touch(r)

Expand Down

0 comments on commit 2f11c69

Please sign in to comment.