Skip to content

Commit 75e31b9

Browse files
authored
move suffix logic under parent.exists
1 parent 54080c1 commit 75e31b9

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

neo/io/__init__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,14 +451,13 @@ def list_candidate_ios(file_or_folder, ignore_patterns=['*.ini', 'README.txt', '
451451
# if only file prefix was provided, e.g /mydatafolder/session1-
452452
# to select all files sharing the `session1-` prefix
453453
elif file_or_folder.parent.exists():
454-
filenames = file_or_folder.parent.glob(file_or_folder.name + '*')
454+
filenames = list(file_or_folder.parent.glob(file_or_folder.name + '*'))
455+
if len(filenames)==0 and file_or_folder.suffix:
456+
suffix = file_or_folder.suffix[1:].lower()
457+
if suffix not in io_by_extension:
458+
raise ValueError(f'{suffix} is not a supported format of any IO.')
459+
return io_by_extension[suffix]
455460

456-
elif file_or_folder.suffix:
457-
suffix = file_or_folder.suffix[1:].lower()
458-
if suffix not in io_by_extension:
459-
raise ValueError(f'{suffix} is not a supported format of any IO.')
460-
return io_by_extension[suffix]
461-
462461
else:
463462
raise ValueError(f'{file_or_folder} does not contain data files of a supported format')
464463

0 commit comments

Comments
 (0)