Skip to content

Commit b82ebce

Browse files
committed
introduce option to ignore system file extensions for more reliable io detection
1 parent c5caf1e commit b82ebce

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

neo/io/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,16 @@ def get_io(file_or_folder, *args, **kwargs):
410410
raise IOError(f"Could not identify IO for {file_or_folder}")
411411

412412

413-
def list_candidate_ios(file_or_folder):
413+
def list_candidate_ios(file_or_folder, ignore_suffix=['ini']):
414414
"""
415415
Identify neo IO that can potentially load data in the file or folder
416416
417417
Parameters
418418
----------
419419
file_or_folder (str, pathlib.Path)
420420
Path to the file or folder to load
421+
ignore_suffix (list)
422+
List of suffixes to ignore when scanning for known formats. Default: ['ini']
421423
422424
Returns
423425
-------
@@ -435,11 +437,15 @@ def list_candidate_ios(file_or_folder):
435437
elif file_or_folder.is_dir():
436438
# scan files in folder to determine io type
437439
filenames = [f for f in file_or_folder.glob('*') if f.is_file()]
440+
# keep only relevant filenames
441+
filenames = [f for f in filenames if f.suffix and f.suffix[1:].lower() not in ignore_suffix]
438442

439443
# if no files are found in the folder, check subfolders
440444
# this is necessary for nested-folder based formats like spikeglx
441445
if not filenames:
442446
filenames = [f for f in file_or_folder.glob('**/*') if f.is_file()]
447+
# keep only relevant filenames
448+
filenames = [f for f in filenames if f.suffix and f.suffix[1:].lower() not in ignore_suffix]
443449

444450
# if only file prefix was provided, e.g /mydatafolder/session1-
445451
# to select all files sharing the `session1-` prefix

0 commit comments

Comments
 (0)