Skip to content

Add a global filter to fs.walk.Walker #459

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

Closed
atollk opened this issue Mar 19, 2021 · 0 comments · Fixed by #464
Closed

Add a global filter to fs.walk.Walker #459

atollk opened this issue Mar 19, 2021 · 0 comments · Fixed by #464

Comments

@atollk
Copy link
Member

atollk commented Mar 19, 2021

fs.walk.Walker can take filter and exclude parameters to include/exclude certain file base names, as well as filter_dirs and exclude_dirs parameters to include/exclude entire directories.

My suggestion is to introduce two new parameters, filter_glob and exclude_glob, to work on arbitrary path objects. This would make working with filters mixed of both directories and files much easier.

For example, consider a file system with three files:

foo/a.py
foo/b.py
bar/a.py

Walking over all files except for foo/a.py is, afaik, impossible with the current Walker functionality. My suggestion would allow for:

fs.walk.Walker(filter_glob=["/"], exclude_glob=["/foo/a.py"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants