Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
GH-73991: Support preserving metadata in pathlib.Path.copy()#120806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Conversation
barneygale commented Jun 20, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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. In the pathlib ABCs we copy the file permissions with `PathBase.chmod()` where supported. In the future we might want to support a more generic public interface for copying metadata between different types of `PathBase` object, but it would be premature here.
bedevere-bot commented Jul 6, 2024
|
Follow-up to python#120806. Use `os_helper.skip_unless_xattr` to skip testing xattr preservation when unsupported.
…ython#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.
…thon#121444) Follow-up to python#120806. Use `os_helper.skip_unless_xattr` to skip testing xattr preservation when unsupported.
…ython#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.
…thon#121444) Follow-up to python#120806. Use `os_helper.skip_unless_xattr` to skip testing xattr preservation when unsupported.
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, likeshutil.copystat(). The argument has no effect on Windows, where metadata is always copied.Internally (in the pathlib ABCs), path types gain
_readable_metadataand_writable_metadataattributes. These sets of strings describe what kinds of metadata can be retrieved and stored. We take an intersection ofsource._readable_metadataandtarget._writable_metadatato 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.📚 Documentation preview 📚: https://cpython-previews--120806.org.readthedocs.build/