Message 336437 - Python tracker (original) (raw)
Findfiles was more like os.walk than os.listdir. os.walk now uses os.scandir instead of os.listdir. From 3.7.2 doc:
"By default, errors from the scandir() call are ignored. If optional argument onerror is specified, it should be a function; it will be called with one argument, an OSError instance. It can report the error to continue with the walk, or raise the exception to abort the walk. Note that the filename is available as the filename attribute of the exception object."
We should delete the try: except: and pass in a function to print the name and error message. This could be done after getting a working patch.
Defaults are not needed as findfiles is called with 3 positional args. The calling method should do the replacement of '' with os.curdir().
The patch must be incomplete as generators do not have a sort method. Replace the first 3 lines of grep_it with
folder, filepat = os.path.split(path)
if not folder:
folder = os.curdir()
filelist = sorted(findfiles(folder, filepat, self.recvar.get())
and replace 'list' with 'filelist' in the following code.
Cheryl, grab the issue if you want to do this.