| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
When a path object is generated by `PathBase.iterdir()`, then its `_info` attribute now stores a `os.DirEntry`-like object that can be used to query the file type. This removes any need for a `_scandir()` method. Currently the `_info` attribute is private and only guaranteed to be populated in paths from `iterdir()`. Later on, I'm hoping to rename it to `info` and ensure that it's populated for all kinds of paths (this probably involves adding a `pathlib.FileInfo` class.) In the pathlib ABCs, `info` will replace `stat()` as the lowest-level abstract file status querying mechanism.
|
Steve - hopefully this helps address the issues you raised in #127377, but perhaps I'm only moving the problem around here. |
Sorry, something went wrong.
|
I think this is just moving stuff around. It might end up being the right places, but let's see the Discourse discussion play out a bit first. |
Sorry, something went wrong.
|
I've revised the PR to be a more complete implementation of what I described on the forum, mostly as a demonstration/proof-of-concept at this stage. |
Sorry, something went wrong.
|
Right, I think this is ready for review. Alyssa, sorry if this seems like deja-vu! |
Sorry, something went wrong.
There was a problem hiding this comment.
This looks great, thank you!
I do have a nitpick:
Sorry, something went wrong.
Co-authored-by: Petr Viktorin <encukou@gmail.com>
|
Thank you Petr :) I'll wait another month until I merge, in case Alyssa or Steve have feedback |
Sorry, something went wrong.
|
I'll merge this on Friday if there's no further feedback. Cheers |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Add pathlib.Path.info attribute, which stores an object implementing the pathlib.types.PathInfo protocol (also new). The object supports querying the file type and internally caching os.stat() results. Path objects generated by Path.iterdir() are initialised with status information from os.DirEntry objects, which is gleaned from scanning the parent directory.
The PathInfo protocol has four methods: exists(), is_dir(), is_file() and is_symlink().