(basePath, validExts=None, contains=None)
| 10 | |
| 11 | |
| 12 | def list_files(basePath, validExts=None, contains=None): |
| 13 | # loop over the directory structure |
| 14 | for (rootDir, dirNames, filenames) in os.walk(basePath): |
| 15 | # loop over the filenames in the current directory |
| 16 | for filename in filenames: |
| 17 | # if the contains string is not none and the filename does not contain |
| 18 | # the supplied string, then ignore the file |
| 19 | if contains is not None and filename.find(contains) == -1: |
| 20 | continue |
| 21 | |
| 22 | # determine the file extension of the current file |
| 23 | ext = filename[filename.rfind("."):].lower() |
| 24 | |
| 25 | # check to see if the file is an image and should be processed |
| 26 | if validExts is None or ext.endswith(validExts): |
| 27 | # construct the path to the image and yield it |
| 28 | imagePath = os.path.join(rootDir, filename) |
| 29 | yield imagePath |
no outgoing calls
no test coverage detected
searching dependent graphs…