| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
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 can delete the `CopyReader` and `LocalCopyReader` classes. Rather than reading metadata 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.
(not 100% sure about this)
|
Should _file_id return a (st_dev, st_ino) tuple? AFAIK, separating them is only due to a low-level detail (you don't need to store st_dev on the disk).
Is that the plan? It seems to me that people will want their subclasses to support such copying, and are might resort to underscored functions to get it. |
Sorry, something went wrong.
Sounds good to me. Would we (eventually) document it as returning (st_dev, st_ino), or should we just say "some comparable/hashable object"?
Yes, I think it will be part of the PEP for making Joinable/Readable/WritablePath public. |
Sorry, something went wrong.
The tuple for the local FS†, a comparable/hashable object in general? I can imagine a path class that would add extra functionality to Path (or limit the functionality), but expose local files. |
Sorry, something went wrong.
|
Thanks :) I've deleted _device_id(), and made _file_id() return (st_dev, st_ino) |
Sorry, something went wrong.
|
Thanks for the review! |
Sorry, something went wrong.
Replace `WritablePath._copy_writer` with a new `_write_info()` method. This method allows the target of a `copy()` to preserve metadata. Replace `pathlib._os.CopyWriter` and `LocalCopyWriter` classes with new `copy_file()` and `copy_info()` functions. The `copy_file()` function uses `source_path.info` wherever possible to save on `stat()`s.
| Back | FazBrowse Home | New Git URL |
Add the following private methods to pathlib.Path.info:
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.