Skip to content

Commit 255fdfc

Browse files
Laurent Guerardehrenfeu
authored andcommitted
fix(listdir): use absolute paths for matching files in listdir_matching
1 parent 6e3ce32 commit 255fdfc

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/imcflibs/pathtools.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ def listdir_matching(
231231
if not regex_compiled:
232232
if candidate.lower().endswith(suffix.lower()):
233233
if fullpath:
234-
matching_files.append(os.path.join(dirpath, candidate))
234+
matching_files.append(
235+
os.path.abspath(os.path.join(dirpath, candidate))
236+
)
235237
else:
236238
rel = os.path.relpath(
237239
os.path.join(dirpath, candidate), path
@@ -240,7 +242,9 @@ def listdir_matching(
240242
else:
241243
if regex_compiled.match(candidate):
242244
if fullpath:
243-
matching_files.append(os.path.join(dirpath, candidate))
245+
matching_files.append(
246+
os.path.abspath(os.path.join(dirpath, candidate))
247+
)
244248
else:
245249
rel = os.path.relpath(
246250
os.path.join(dirpath, candidate), path
@@ -252,13 +256,17 @@ def listdir_matching(
252256
if not regex_compiled:
253257
if candidate.lower().endswith(suffix.lower()):
254258
if fullpath:
255-
matching_files.append(os.path.join(path, candidate))
259+
matching_files.append(
260+
os.path.abspath(os.path.join(path, candidate))
261+
)
256262
else:
257263
matching_files.append(candidate)
258264
else:
259265
if regex_compiled.match(candidate):
260266
if fullpath:
261-
matching_files.append(os.path.join(path, candidate))
267+
matching_files.append(
268+
os.path.abspath(os.path.join(path, candidate))
269+
)
262270
else:
263271
matching_files.append(candidate)
264272

0 commit comments

Comments
 (0)