Skip to content

Commit 5012491

Browse files
DirFileSystem.mv should call the underlying fs
1 parent b532078 commit 5012491

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

fsspec/implementations/dirfs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,15 @@ def makedirs(self, path, *args, **kwargs):
329329
def rmdir(self, path):
330330
return self.fs.rmdir(self._join(path))
331331

332-
def mv_file(self, path1, path2, **kwargs):
333-
return self.fs.mv_file(
332+
def mv(self, path1, path2, **kwargs):
333+
return self.fs.mv(
334334
self._join(path1),
335335
self._join(path2),
336336
**kwargs,
337337
)
338338

339+
mv_file = mv
340+
339341
def touch(self, path, **kwargs):
340342
return self.fs.touch(self._join(path), **kwargs)
341343

fsspec/implementations/local.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,13 @@ def get_file(self, path1, path2, callback=None, **kwargs):
150150
def put_file(self, path1, path2, callback=None, **kwargs):
151151
return self.cp_file(path1, path2, **kwargs)
152152

153-
def mv_file(self, path1, path2, **kwargs):
153+
def mv(self, path1, path2, **kwargs):
154154
path1 = self._strip_protocol(path1, remove_trailing_slash=True)
155155
path2 = self._strip_protocol(path2, remove_trailing_slash=True)
156156
shutil.move(path1, path2)
157157

158+
mv_file = mv
159+
158160
def link(self, src, dst, **kwargs):
159161
src = self._strip_protocol(src)
160162
dst = self._strip_protocol(dst)

fsspec/implementations/tests/test_dirfs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,10 +542,10 @@ def test_rmdir(mocker, dirfs):
542542
dirfs.fs.rmdir.assert_called_once_with(f"{PATH}/dir")
543543

544544

545-
def test_mv_file(mocker, dirfs):
546-
dirfs.fs.mv_file = mocker.Mock()
547-
dirfs.mv_file("one", "two", **KWARGS)
548-
dirfs.fs.mv_file.assert_called_once_with(f"{PATH}/one", f"{PATH}/two", **KWARGS)
545+
def test_mv(mocker, dirfs):
546+
dirfs.fs.mv = mocker.Mock()
547+
dirfs.mv("one", "two", **KWARGS)
548+
dirfs.fs.mv.assert_called_once_with(f"{PATH}/one", f"{PATH}/two", **KWARGS)
549549

550550

551551
def test_touch(mocker, dirfs):

0 commit comments

Comments
 (0)