MCPcopy Create free account
hub / github.com/PyImageSearch/imutils / list_files

Function list_files

imutils/paths.py:12–29  ·  view source on GitHub ↗
(basePath, validExts=None, contains=None)

Source from the content-addressed store, hash-verified

10
11
12def 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

Callers 1

list_imagesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…