Generate file names in dir that match pattern. Args: folder: Root directory to search. pattern: File pattern to match. recursive: True to include subdirectories.
(folder, pattern, recursive)
| 46 | |
| 47 | |
| 48 | def findfiles(folder, pattern, recursive): |
| 49 | """Generate file names in dir that match pattern. |
| 50 | |
| 51 | Args: |
| 52 | folder: Root directory to search. |
| 53 | pattern: File pattern to match. |
| 54 | recursive: True to include subdirectories. |
| 55 | """ |
| 56 | for dirpath, _, filenames in os.walk(folder, onerror=walk_error): |
| 57 | yield from (os.path.join(dirpath, name) |
| 58 | for name in filenames |
| 59 | if fnmatch.fnmatch(name, pattern)) |
| 60 | if not recursive: |
| 61 | break |
| 62 | |
| 63 | |
| 64 | class GrepDialog(SearchDialogBase): |