File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ def jython_fiji_exists(path):
7676 return False
7777
7878
79- def listdir_matching (path , suffix ):
79+ def listdir_matching (path , suffix , fullpath = False ):
8080 """Get a list of files in a directory matching a given suffix.
8181
8282 Parameters
@@ -85,6 +85,10 @@ def listdir_matching(path, suffix):
8585 The directory to scan for files.
8686 suffix : str
8787 The suffix to match filenames against.
88+ fullpath : bool, optional
89+ If set to True, the list returned by the function will contain the full
90+ paths to the matching files (the default is False, which will result in
91+ the file names only, without path).
8892
8993 Returns
9094 -------
@@ -95,7 +99,10 @@ def listdir_matching(path, suffix):
9599 for candidate in os .listdir (path ):
96100 if candidate .lower ().endswith (suffix .lower ()):
97101 # log.debug("Found file %s", candidate)
98- matching_files .append (candidate )
102+ if fullpath :
103+ matching_files .append (os .path .join (path , candidate ))
104+ else :
105+ matching_files .append (candidate )
99106
100107 return matching_files
101108
You can’t perform that action at this time.
0 commit comments