Skip to content
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

GH-101112: Provide pattern overview for Path.glob #101223

Closed

Conversation

jugmac00
Copy link
Contributor

@jugmac00 jugmac00 commented Jan 21, 2023

Provide an overview of available patterns for Path.glob and reference it from Path.rglob and Path.match.

@jugmac00 jugmac00 requested a review from barneygale as a code owner January 21, 2023 15:39
@bedevere-bot bedevere-bot added docs Documentation in the Doc dir skip news labels Jan 21, 2023
@jugmac00 jugmac00 force-pushed the show-syntax-table-for-path-pattern branch from 9365d78 to 8510576 Compare January 21, 2023 15:39
@jugmac00 jugmac00 changed the title GH-101112: Provide pattern overview for Path.glob GH-101112: Provide pattern overview for Path.glob Jan 21, 2023
@barneygale
Copy link
Contributor

Thanks for the PR, this will be very helpful.

The table isn't quite right:

  • ** doesn't match everything - it matches any number of nested directories.
  • The other wildcards (*, [seq], [!seq]) never match directory separators. They only match parts of file or directory names.

@jugmac00 jugmac00 force-pushed the show-syntax-table-for-path-pattern branch from 55b0bb1 to 23b12d4 Compare January 21, 2023 16:52
@jugmac00
Copy link
Contributor Author

jugmac00 commented Jan 21, 2023

@barneygale Thanks for catching. I copied the fnmatch table for the layout and missed to update it with the information you provided. Sorry for that.

@jugmac00
Copy link
Contributor Author

@barneygale Thanks for being patient and driving me through this PR.

I applied your requested changes, but I think I am a bit lost regarding the fine details. I probably misinterpreted your comment in #101112 (comment) where you mentioned that that fnmatch reference is not correct.

I am happy to further update this PR, but feel free to directly push to it if you see anything to be improved to get this PR moved forwards.

Thanks a lot for your time!

Provide an overview of available patterns for `Path.glob` and reference
it from `Path.rglob` and `Path.match`.

Co-authored-by: Barney Gale <barney.gale@gmail.com>
@jugmac00 jugmac00 force-pushed the show-syntax-table-for-path-pattern branch from ab1f568 to 6fc4c85 Compare January 21, 2023 20:04
@barneygale barneygale self-requested a review January 27, 2023 03:34
Match this path against the provided glob-style pattern. Return ``True``
if matching is successful, ``False`` otherwise.
Match this path against the provided glob-style pattern. The pattern uses
the same format as in :func:`Path.glob`. Return ``True`` if matching is
Copy link
Contributor

@barneygale barneygale Jun 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the same format as in :func:`Path.glob`. Return ``True`` if matching is
the same format as in :meth:`Path.glob`. Return ``True`` if matching is

@@ -1331,8 +1348,7 @@ call fails (for example because the path doesn't exist).
.. method:: Path.rglob(pattern, *, case_sensitive=None, follow_symlinks=None)

Glob the given relative *pattern* recursively. This is like calling
:func:`Path.glob` with "``**/``" added in front of the *pattern*, where
*patterns* are the same as for :mod:`fnmatch`::
:func:`Path.glob` with "``**/``" added in front of the *pattern*::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:func:`Path.glob` with "``**/``" added in front of the *pattern*::
:meth:`~Path.glob` with "``**/``" added in front of the *pattern*::

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@barneygale
Copy link
Contributor

Sorry for the long delay. PurePath.match() now supports **/ tokens, so I've removed the bit about it being different to glob().

@barneygale
Copy link
Contributor

Issue was fixed in #114030, so I'm closing this PR. Thanks all the same.

@barneygale barneygale closed this Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants