Skip to content

Commit

Permalink
add get_subfolders helper to paths
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDonoghue committed Apr 25, 2024
1 parent 8140fd9 commit f23b248
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 8 additions & 2 deletions convnwb/paths/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from copy import deepcopy
from pathlib import Path

from convnwb.io.utils import get_files, make_session_name
from convnwb.io.utils import get_files, get_subfolders, make_session_name

from convnwb.paths.defaults import PROJECT_FOLDERS, SUBJECT_FOLDERS, SESSION_FOLDERS

Expand Down Expand Up @@ -101,6 +101,12 @@ def session(self):


def get_files(self, folder, **kwargs):
"""Get a list of files available in a specified sub-folder."""
"""Get a list of files available in a specified folder."""

return get_files(getattr(self, folder), **kwargs)


def get_subfolders(self, folder, **kwargs):
"""Get a list of sub-folder available in a specified folder."""

return get_subfolders(getattr(self, folder), **kwargs)
8 changes: 7 additions & 1 deletion convnwb/tests/paths/test_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_paths():
for subdir in PROJECT_FOLDERS:
assert getattr(paths, subdir)

def test_paths_get_files():
def test_paths_get_files_n_folders():

subject = 'test_subject'
task = 'test_task'
Expand All @@ -53,9 +53,15 @@ def test_paths_get_files():
for subfolder in subfolders:
files = paths.get_files(subdir)
assert isinstance(files, list)
subfolders = paths.get_subfolders(subdir)
assert isinstance(subfolders, list)
for subdir in SUBJECT_FOLDERS:
files = paths.get_files(subdir)
assert isinstance(files, list)
subfolders = paths.get_subfolders(subdir)
assert isinstance(subfolders, list)
for subdir in PROJECT_FOLDERS:
files = paths.get_files(subdir)
assert isinstance(files, list)
subfolders = paths.get_subfolders(subdir)
assert isinstance(subfolders, list)

0 comments on commit f23b248

Please sign in to comment.