diff --git a/fsspec/implementations/dirfs.py b/fsspec/implementations/dirfs.py index 0f3dd3cf4..65b9b5da1 100644 --- a/fsspec/implementations/dirfs.py +++ b/fsspec/implementations/dirfs.py @@ -97,6 +97,9 @@ async def _rm(self, path, *args, **kwargs): def rm(self, path, *args, **kwargs): return self.fs.rm(self._join(path), *args, **kwargs) + def delete(self, path, recursive=False, maxdepth=None): + return self.fs.delete(self._join(path), recursive=recursive, maxdepth=maxdepth) + async def _cp_file(self, path1, path2, **kwargs): return await self.fs._cp_file(self._join(path1), self._join(path2), **kwargs) @@ -137,6 +140,18 @@ async def _pipe_file(self, path, *args, **kwargs): def pipe_file(self, path, *args, **kwargs): return self.fs.pipe_file(self._join(path), *args, **kwargs) + def write_text( + self, path, value, encoding=None, errors=None, newline=None, **kwargs + ): + return self.fs.write_text( + self._join(path), + value, + encoding=encoding, + errors=errors, + newline=newline, + **kwargs, + ) + async def _cat_file(self, path, *args, **kwargs): return await self.fs._cat_file(self._join(path), *args, **kwargs) diff --git a/fsspec/implementations/tests/test_dirfs.py b/fsspec/implementations/tests/test_dirfs.py index f58969406..5f2b51731 100644 --- a/fsspec/implementations/tests/test_dirfs.py +++ b/fsspec/implementations/tests/test_dirfs.py @@ -141,6 +141,13 @@ def test_rm(dirfs): dirfs.fs.rm.assert_called_once_with("path/to/dir/file", *ARGS, **KWARGS) +def test_delete(dirfs): + dirfs.delete("file", recursive=True, maxdepth=2) + dirfs.fs.delete.assert_called_once_with( + "path/to/dir/file", recursive=True, maxdepth=2 + ) + + @pytest.mark.asyncio async def test_async_cp_file(adirfs): await adirfs._cp_file("one", "two", **KWARGS) @@ -192,6 +199,13 @@ def test_pipe_file(dirfs): dirfs.fs.pipe_file.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS) +def test_write_text(dirfs): + dirfs.write_text("file", "value", encoding="utf-8", newline="\n") + dirfs.fs.write_text.assert_called_once_with( + "path/to/dir/file", "value", encoding="utf-8", errors=None, newline="\n" + ) + + @pytest.mark.asyncio async def test_async_cat_file(adirfs): assert (