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

bpo-36898: Add parameter @case_sensitive to glob and rglob in pathlib #13274

Closed
wants to merge 1 commit into from

Conversation

monchin
Copy link

@monchin monchin commented May 13, 2019

In pathlib, I add a parameter case_sensitive to glob and rglob.

Sometimes the extension would be in upper case but sometimes it would be lower case, for example: *.tif and *.TIF. So the parameter case_sensitive may be useful in some cases.

Usage example:

In [1]: from pathlib import Path

In [2]: path = Path('.')

In [3]: for each_file in path.glob('*.tif'):
   ...:     print(each_file)
   ...:     
a.tif
b.tif

In [4]: for each_file in path.rglob('*.TIF'):
   ...:     print(each_file)
   ...:     
c.TIF
TEST/d.TIF

In [5]: for each_file in path.glob('*.TIF', case_sensitive=False):
   ...:     print(each_file)
   ...:     
a.tif
c.TIF
b.tif

In [6]: for each_file in path.rglob('*.TIF', case_sensitive=False):
   ...:     print(each_file)
   ...:     
a.tif
c.TIF
b.tif
TEST/d.TIF
TEST/e.tif

https://bugs.python.org/issue36898

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

@monchin monchin changed the title Add parameter @case_sensitive to glob and rglob in pathlib bpo-36898: Add parameter @case_sensitive to glob and rglob in pathlib May 13, 2019
Copy link
Contributor

@eamanu eamanu left a comment

Choose a reason for hiding this comment

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

I think that this is a good improve.

You need to write tests and NEW file.

Don't forget sign the CLA :-)

@brettcannon
Copy link
Member

Thanks for the PR, but closing as the CLA has not been signed within the last month. If you do decide to sign the CLA we can re-open this PR.

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.

5 participants