mirror of
https://github.com/python/cpython.git
synced 2025-10-31 21:51:50 +00:00
GH-125413: Add private metadata methods to pathlib.Path.info (#129897)
Add the following private methods to `pathlib.Path.info`: - `_posix_permissions()`: the POSIX file permissions (`S_IMODE(st_mode)`) - `_file_id()`: the file ID (`(st_dev, st_ino)`) - `_access_time_ns()`: the access time in nanoseconds (`st_atime_ns`) - `_mod_time_ns()`: the modify time in nanoseconds (`st_mtime_ns`) - `_bsd_flags()`: the BSD file flags (`st_flags`) - `_xattrs()`: the file extended attributes as a list of key, value pairs, or an empty list if `listxattr()` or `getxattr()` fail in an ignorable way. These methods replace `LocalCopyReader.read_metadata()`, and so we can delete the `CopyReader` and `LocalCopyReader` classes. Rather than reading metadata via `source._copy_reader.read_metadata()`, we instead call `source.info._posix_permissions()`, `_access_time_ns()`, etc. Preserving metadata is only supported for local-to-local copies at the moment. To support copying metadata between arbitrary `ReadablePath` and `WritablePath` objects, we'd need to make the new methods public and documented. Co-authored-by: Petr Viktorin <encukou@gmail.com>
This commit is contained in:
parent
bd1642c6e5
commit
7fcace99bb
4 changed files with 205 additions and 207 deletions
|
|
@ -14,7 +14,7 @@
|
|||
from abc import ABC, abstractmethod
|
||||
from glob import _PathGlobber, _no_recurse_symlinks
|
||||
from pathlib import PurePath, Path
|
||||
from pathlib._os import magic_open, CopyReader, CopyWriter
|
||||
from pathlib._os import magic_open, CopyWriter
|
||||
|
||||
|
||||
def _explode_path(path):
|
||||
|
|
@ -353,8 +353,6 @@ def readlink(self):
|
|||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
_copy_reader = property(CopyReader)
|
||||
|
||||
def copy(self, target, follow_symlinks=True, dirs_exist_ok=False,
|
||||
preserve_metadata=False):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue