mutapath.MutaPath.moving

MutaPath.moving(lock=True, timeout=1, method: Callable[[os.PathLike, os.PathLike], str] = <function move>)[source]

Create a moving context for this immutable path. The external value is only changed if the moving succeeds.

Parameters
  • timeout – the timeout in seconds how long the lock file should be acquired

  • lock – if the source file should be locked as long as this context is open

  • method – an alternative method that moves the path and returns the new path

Example

>>> with Path('/home/doe/folder/a.txt').moving() as mut:
...     mut.stem = "b"
Path('/home/doe/folder/b.txt')