Add filter_glob and exclude_glob to fs.walk#464
Add filter_glob and exclude_glob to fs.walk#464althonos merged 2 commits intoPyFilesystem:masterfrom
filter_glob and exclude_glob to fs.walk#464Conversation
althonos
left a comment
There was a problem hiding this comment.
Nice job once again 😉
My largest concern is about whether it would be possible to remove the _translate function completely, and use _PatternMatcher in fs.glob as well to reduce code duplication. Otherwise, it's mostly smaller stuff.
I'll have a closer look at the actual files at some point because GitHub diffs are really not helping here, but the first read didn't raise any red flag 😄
|
Alright, so, after taking a step back and having a look at the larger picture again, it made more sense to me to put all that logic into Either way, several of your previous comments became obsolete through this and I implemented the rest (like |
|
Hi. Any update on this? |
|
I just rebased this branch onto the newest |
|
@atollk : I think you rebased against your old |
|
@althonos Should be fine now. |
| patterns (list, optional): A list of patterns, e.g. | ||
| ``['*.py']``, or `None` to match everything. |
There was a problem hiding this comment.
Looking at just the doc-strings, it's hard to see how match_glob() is different from match() ?
There was a problem hiding this comment.
The summaries (first sentences) differ: Check if a name matches any of a list of wildcards. and Check if a path matches any of a list of glob patterns..
| if path and path[0] != "/": | ||
| path = "/" + path |
There was a problem hiding this comment.
Is this the same as https://docs.pyfilesystem.org/en/latest/reference/path.html#fs.path.abspath ?
There was a problem hiding this comment.
Only with the current implementation of abspath, not with the general idea.
|
Sorry for not getting this merged sooner, I've been under lots of work for my research projects. @atollk has definitely done a lot of work on this, and the reason I've been stalling this PR a bit is probably because I was not 100% happy with the API, but honestly I can't come up with something better, so I will merge this ASAP, and we can always refactor in the |
|
Looks like there's a bunch of conflicts that need to be resolved first though 😕 |
These extend the class by an option to include/exclude resources by their entire path, not just its last component. To do so, fs.wildcard had to undergo a rework to remove the dependency on the `re` module. Unit tests were added for all new/changed code.
|
done |
|
I'd just like #542 to be merged first and then we'll get a new release 👍 |
Type of changes
Checklist
Description
Fixes #371. Fixes #459 .
Added parameters
filter_globandexclude_globtofs.walk.Walkerto perform selection on the walked resources based on their global path.