Cheryl Sabella <cheryl.sabe...@gmail.com> added the comment:
I've opened a PR with the changes. I did several commits, one for each stage. That is, the first one adds the test, then the second one moves `findfiles` to the module level, etc. I added the `onerror` function because if a directory that doesn't exist is entered as the path, it's nice to see that message at the top of the output window instead of just seeing zero hits. Plus, I had made a test for it. :-) One change that I didn't commit is that an alternative version of findfiles would be: def findfiles(folder, pattern, recursive): prefix = '**/' if recursive else '' yield from(pathlib.Path(folder).glob(f'{prefix}{pattern}')) The tests would have to be reworked, but manual testing showed it gave the same results, albeit without the `onerror`. One other comment about the sorting. If you change the `sorted()` in `grep_it()` to `list()` when you're looking at manual results, you'll see that `list()` shows all of one directory first, then all of the first child directory, etc (which makes sense since walk does each directory at a time). It's a quick way to compare the depth-first vs breadth first results. ---------- stage: patch review -> needs patch _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue23205> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com