Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
GH-73435: Addpathlib.PurePath.full_match()
#114350
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
In49f90ba we added support for the recursive wildcard `**` in`pathlib.PurePath.match()`. This should allow arbitrary prefix and suffixmatching, like `p.match('foo/**')` or `p.match('**/foo')`, but there's aproblem: for relative patterns only, `match()` implicitly inserts a `**`token on the left hand side, causing all patterns to match from the right.As a result, it's impossible to match relative patterns from the left:`PurePath('foo/bar').match('bar/**')` is true!This commit reverts the changes to `match()`, and instead adds a new`globmatch()` method that:- Supports the recursive wildcard `**`- Matches the *entire* path when given a relative patternAs a result, `globmatch()`'s pattern language exactly matches that of`glob()`.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Does the problem extend beyond " Presumably |
|
e.g.zsh man page:
|
Okay, I definitely like having |
pathlib.PurePath.globmatch()
pathlib.PurePath.full_match()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM
Uh oh!
There was an error while loading.Please reload this page.
Thanks for the reviews, both. |
In49f90ba we added support for the recursive wildcard `**` in`pathlib.PurePath.match()`. This should allow arbitrary prefix and suffixmatching, like `p.match('foo/**')` or `p.match('**/foo')`, but there's aproblem: for relative patterns only, `match()` implicitly inserts a `**`token on the left hand side, causing all patterns to match from the right.As a result, it's impossible to match relative patterns from the left:`PurePath('foo/bar').match('bar/**')` is true!This commit reverts the changes to `match()`, and instead adds a new`full_match()` method that:- Allows empty patterns- Supports the recursive wildcard `**`- Matches the *entire* path when given a relative pattern
In49f90ba we added support for the recursive wildcard `**` in`pathlib.PurePath.match()`. This should allow arbitrary prefix and suffixmatching, like `p.match('foo/**')` or `p.match('**/foo')`, but there's aproblem: for relative patterns only, `match()` implicitly inserts a `**`token on the left hand side, causing all patterns to match from the right.As a result, it's impossible to match relative patterns from the left:`PurePath('foo/bar').match('bar/**')` is true!This commit reverts the changes to `match()`, and instead adds a new`full_match()` method that:- Allows empty patterns- Supports the recursive wildcard `**`- Matches the *entire* path when given a relative pattern
Uh oh!
There was an error while loading.Please reload this page.
In#101398 we added support for the recursive wildcard
**
inpathlib.PurePath.match()
. This should allow arbitrary prefix and suffix matching, likep.match('foo/**')
orp.match('**/foo')
, but there's a problem: for relative patterns only,match()
implicitly inserts a**
token on the left hand side, causing all patterns to match from the right. As a result, it's impossible to match relative patterns from the left:PurePath('foo/bar').match('bar/**')
is true!This PR reverts the changes to
match()
, and instead adds a newfull_match()
method that:**
📚 Documentation preview 📚:https://cpython-previews--114350.org.readthedocs.build/en/114350/library/pathlib.html#pathlib.PurePath.globmatch