pathlib-abc
pathlib-abc copied to clipboard
Add `WritablePath.copy_from()`
To support metadata transfers, we need to add a method to WritablePath that allows receivers to copy metadata from some ReadablePath source. Currently we have _copy_from(), but it's got an underscore prefix.
This will affect pathlib.Path
Perhaps the method should return an iterator that emits progress reports? If so can someone come up with a better name than iter_copy_from()? :)
See also https://github.com/python/cpython/pull/131636
Alternatively:
- Add
PathInfo.mode(),access_time()andmodify_time()methods. - Add keyword-only info arguments to
__open_writer__(),mkdir()andsymlink_to(). If notNone, methods are expected to copy metadata from thePathInfoobject when creating files/directories/symlinks. - Implementations of these methods for (local filesystem)
Pathwould apply the equivalent of the 'data' filter for tar files: https://docs.python.org/3/library/tarfile.html#tarfile.data_filter__open_writer__()- access/modify times and limited permissions infomkdir()- access/modify times onlysymlink_to()- access/modify times only
- Implementation of
ReadablePath.copy()should call these methods rather thantarget._copy_from(). - Implementation of
Path.copy()should detect a local filesystem target and apply additional metadata withchmod()etc- xattrs
- bsd flags
- full permissions