Skip to content

Commit

Permalink
fix(dirfs): allow protocol prefixed paths (#1307)
Browse files Browse the repository at this point in the history
* fix(dirfs): allow protocol prefixed paths

* lint

---------

Co-authored-by: Martin Durant <[email protected]>
  • Loading branch information
Mause and martindurant authored Jul 10, 2023
1 parent 3b55be9 commit 0071252
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fsspec/implementations/dirfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class DirFileSystem(AsyncFileSystem):
delegates everything to the wrapped filesystem.
"""

protocol = "dirfs"

def __init__(
self,
path=None,
Expand Down Expand Up @@ -53,7 +55,7 @@ def _join(self, path):
return path
if not path:
return self.path
return self.fs.sep.join((self.path, path))
return self.fs.sep.join((self.path, self._strip_protocol(path)))
return [self._join(_path) for _path in path]

def _relpath(self, path):
Expand Down
6 changes: 6 additions & 0 deletions fsspec/implementations/tests/test_dirfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ def test_glob(dirfs):
dirfs.fs.glob.assert_called_once_with(f"{PATH}/*", **KWARGS)


def test_glob_with_protocol(dirfs):
dirfs.fs.glob.return_value = [f"{PATH}/one", f"{PATH}/two"]
assert dirfs.glob("dirfs://*", **KWARGS) == ["one", "two"]
dirfs.fs.glob.assert_called_once_with(f"{PATH}/*", **KWARGS)


@pytest.mark.asyncio
async def test_async_glob_detail(adirfs):
adirfs.fs._glob.return_value = {
Expand Down

0 comments on commit 0071252

Please sign in to comment.