MCPcopy Index your code
hub / github.com/python/cpython / move

Method move

Lib/pathlib/__init__.py:1369–1390  ·  view source on GitHub ↗

Recursively move this file or directory tree to the given destination.

(self, target)

Source from the content-addressed store, hash-verified

1367 _copy_info(source.info, self, follow_symlinks=False)
1368
1369 def move(self, target):
1370 """
1371 Recursively move this file or directory tree to the given destination.
1372 """
1373 # Use os.replace() if the target is os.PathLike and on the same FS.
1374 try:
1375 target = self.with_segments(target)
1376 except TypeError:
1377 pass
1378 else:
1379 ensure_different_files(self, target)
1380 try:
1381 os.replace(self, target)
1382 except OSError as err:
1383 if err.errno != EXDEV:
1384 raise
1385 else:
1386 return target.joinpath() # Empty join to ensure fresh metadata.
1387 # Fall back to copy+delete.
1388 target = self.copy(target, follow_symlinks=False, preserve_metadata=True)
1389 self._delete()
1390 return target
1391
1392 def move_into(self, target_dir):
1393 """

Callers 2

move_intoMethod · 0.95
waFunction · 0.45

Calls 6

copyMethod · 0.95
_deleteMethod · 0.95
ensure_different_filesFunction · 0.90
with_segmentsMethod · 0.45
replaceMethod · 0.45
joinpathMethod · 0.45

Tested by

no test coverage detected