cpython/Lib/pathlib
Barney Gale 88fc0655d4
GH-73991: Support preserving metadata in `pathlib.Path.copy()` (#120806)
Add *preserve_metadata* keyword-only argument to `pathlib.Path.copy()`, defaulting to false. When set to true, we copy timestamps, permissions, extended attributes and flags where available, like `shutil.copystat()`. The argument has no effect on Windows, where metadata is always copied.

Internally (in the pathlib ABCs), path types gain `_readable_metadata` and `_writable_metadata` attributes. These sets of strings describe what kinds of metadata can be retrieved and stored. We take an intersection of `source._readable_metadata` and `target._writable_metadata` to minimise reads/writes. A new `_read_metadata()` method accepts a set of metadata keys and returns a dict with those keys, and a new `_write_metadata()` method accepts a dict of metadata. We *might* make these public in future, but it's hard to justify while the ABCs are still private.
2024-07-06 17:18:39 +01:00
..
__init__.py GH-73991: Support copying directory symlinks on older Windows (#120807) 2024-07-03 04:30:29 +01:00
_abc.py GH-73991: Support preserving metadata in `pathlib.Path.copy()` (#120806) 2024-07-06 17:18:39 +01:00
_local.py GH-73991: Support preserving metadata in `pathlib.Path.copy()` (#120806) 2024-07-06 17:18:39 +01:00
_os.py GH-73991: Support preserving metadata in `pathlib.Path.copy()` (#120806) 2024-07-06 17:18:39 +01:00