Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-125413: Add private metadata methods topathlib.Path.info#129897

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
barneygale merged 16 commits intopython:mainfrombarneygale:gh-125413-merge-copyreader
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
16 commits
Select commitHold shift + click to select a range
4dd7c21
GH-125413: Add private metadata methods to `pathlib.Path.info`
barneygaleFeb 9, 2025
30faab7
Fix atime/mtime copying
barneygaleFeb 9, 2025
22e065d
Simplify patch
barneygaleFeb 9, 2025
cd4a1b5
Improve naming
barneygaleFeb 9, 2025
07f89a4
Return `None` if results aren't available.
barneygaleFeb 9, 2025
2026886
Merge `_create_metadata()` and `_create_symlink_metadata()`
barneygaleFeb 9, 2025
ba4d393
Simplify patch a bit
barneygaleFeb 9, 2025
6cde4fb
Further reduce diff
barneygaleFeb 9, 2025
0871a39
Stop suppressing stat() errors from new methods
barneygaleFeb 9, 2025
89e49bf
Stop using `samefile()`, add `_file_id()` and `_device_id()`
barneygaleFeb 11, 2025
86b671f
Attempt to fix access time test
barneygaleFeb 12, 2025
f6b2249
Delete `_device_id()`
barneygaleFeb 13, 2025
47616de
Merge branch 'main' into gh-125413-merge-copyreader
barneygaleFeb 13, 2025
bc9032b
Merge branch 'main' into gh-125413-merge-copyreader
barneygaleFeb 16, 2025
6c03d51
Merge branch 'main' into gh-125413-merge-copyreader
encukouFeb 17, 2025
13db1fe
`_create_metadata` -> `_copy_metadata`
barneygaleFeb 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
GH-125413: Add private metadata methods topathlib.Path.info
Add the following private methods to `pathlib.Path.info`:- `_get_mode()`: returns the POSIX file mode (`st_mode`), or zero if  `os.stat()` fails.- `_get_times_ns()`: returns the access and modify times in nanoseconds  (`st_atime_ns` and `st_mtime_ns`), or zeroes if `os.stat()` fails.- `_get_flags()`: returns the BSD file flags (`st_flags`), or zero if  `os.stat()` fails.- `_get_xattrs()`: returns the file extended attributes as a list of  key, value pairs, or an empty list if `listxattr()` or `getattr()` fail.These methods replace `LocalCopyReader.read_metadata()`, and so we candelete the `CopyReader` and `LocalCopyReader` classes. Rather than readingmetadata via `source._copy_reader.read_metadata()`, we instead call`source.info._get_mode()`, `_get_times_ns()`, etc.Copying metadata is only supported for local-to-local copies at the moment.To support copying between arbitrary `ReadablePath` and `WritablePath`objects, we'd need to make the new methods public and documented.
  • Loading branch information
@barneygale
barneygale committedFeb 9, 2025
commit4dd7c21b8f5d0a8045da36a4402e926300140b09
4 changes: 1 addition & 3 deletionsLib/pathlib/_abc.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@
import functools
import posixpath
from glob import _PathGlobber, _no_recurse_symlinks
from pathlib._os import magic_open,CopyReader,CopyWriter
from pathlib._os import magic_open, CopyWriter


@functools.cache
Expand DownExpand Up@@ -354,8 +354,6 @@ def readlink(self):
"""
raise NotImplementedError

_copy_reader = property(CopyReader)

def copy(self, target, follow_symlinks=True, dirs_exist_ok=False,
preserve_metadata=False):
"""
Expand Down
3 changes: 1 addition & 2 deletionsLib/pathlib/_local.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,7 +19,7 @@
except ImportError:
grp = None

from pathlib._os importLocalCopyReader,LocalCopyWriter, PathInfo, DirEntryInfo
from pathlib._os import LocalCopyWriter, PathInfo, DirEntryInfo
from pathlib._abc import JoinablePath, ReadablePath, WritablePath


Expand DownExpand Up@@ -1055,7 +1055,6 @@ def replace(self, target):
os.replace(self, target)
return self.with_segments(target)

_copy_reader = property(LocalCopyReader)
_copy_writer = property(LocalCopyWriter)

def move(self, target):
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp