Skip to content

Commit

Permalink
Replace glob with crawler
Browse files Browse the repository at this point in the history
  • Loading branch information
e-kenneally authored Jun 22, 2024
1 parent 23b1206 commit 4f3ff02
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions bids2table/extractors/bids.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import logging
from glob import iglob
from pathlib import Path
from typing import Generator, Optional
from typing import Generator, List, Optional

from elbow.extractors import extract_file_meta
from elbow.record import Record, concat
from elbow.sources.filesystem import Crawler
from elbow.typing import StrOrPath

from bids2table.entities import BIDSEntities
Expand Down Expand Up @@ -42,12 +43,21 @@ def extract_bids_file(path: StrOrPath, with_meta: bool = True) -> Optional[Recor


def extract_bids_subdir(
path: StrOrPath, with_meta: bool = True
path: StrOrPath, exclude: List[str],
with_meta: bool = True
) -> Generator[Optional[Record], None, None]:
"""
Extract BIDS records recursively for all files in a sub-directory.
"""
for path in iglob(str(Path(path) / "**"), recursive=True):

# replace glob with crawler
source = Crawler(
root=path,
skip=exclude,
follow_links=True,
)

for path in source:
yield extract_bids_file(path, with_meta=with_meta)


Expand Down

0 comments on commit 4f3ff02

Please sign in to comment.