mutapath.MutaPath.copying
- MutaPath.copying(lock=True, timeout=1, method: ~typing.Callable[[~mutapath.immutapath.Path, ~mutapath.immutapath.Path], ~mutapath.immutapath.Path] = <function copy>)[source]
Create a copying context for this immutable path. The external value is only changed if the copying 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 copies the path and returns the new path (e.g., shutil.copy2)
- Example:
>>> with Path('/home/doe/folder/a.txt').copying() as mut: ... mut.stem = "b" Path('/home/doe/folder/b.txt')