From 0b5c672ff628592964beadb6487501b09bbbee96 Mon Sep 17 00:00:00 2001 From: MarsMellow Date: Mon, 18 Sep 2023 18:01:02 +0200 Subject: [PATCH] Revert using is_hidden() because root folders can be hidden --- bidscoin/__init__.py | 6 +++--- bidscoin/bids.py | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bidscoin/__init__.py b/bidscoin/__init__.py index 2d53a524..d5a760f2 100644 --- a/bidscoin/__init__.py +++ b/bidscoin/__init__.py @@ -105,11 +105,11 @@ def is_hidden(path: Path) -> bool: def lsdirs(folder: Path, wildcard: str='*') -> List[Path]: """ - Gets all directories in a folder, ignores files + Gets all directories in a folder, ignores files. Foldernames and files starting with a dot are considered hidden and will be skipped :param folder: The full pathname of the folder - :param wildcard: Simple (glob.glob) shell-style wildcards. Foldernames starting with a dot are considered hidden and will be skipped. Use '**/wildcard for recursive search' + :param wildcard: Simple (glob.glob) shell-style wildcards. Use '**/wildcard for recursive search' :return: A list with all directories in the folder """ - return sorted([fname for fname in sorted(folder.glob(wildcard)) if fname.is_dir() and not is_hidden(fname.relative_to(folder))]) + return sorted([item for item in sorted(folder.glob(wildcard)) if item.is_dir() and not is_hidden(item.relative_to(folder))]) diff --git a/bidscoin/bids.py b/bidscoin/bids.py index 00d2c51f..5ae9edbb 100644 --- a/bidscoin/bids.py +++ b/bidscoin/bids.py @@ -27,7 +27,7 @@ if find_spec('bidscoin') is None: import sys sys.path.append(str(Path(__file__).parents[1])) -from bidscoin import bcoin, schemafolder, heuristicsfolder, bidsmap_template, is_hidden, lsdirs, __version__ +from bidscoin import bcoin, schemafolder, heuristicsfolder, bidsmap_template, lsdirs, __version__ from bidscoin.utilities import dicomsort from ruamel.yaml import YAML yaml = YAML() @@ -444,7 +444,7 @@ def get_dicomfile(folder: Path, index: int=0) -> Path: :return: The filename of the first dicom-file in the folder. """ - if is_hidden(folder): + if folder.name.startswith('.'): LOGGER.verbose(f"Ignoring hidden folder: {folder}") return Path() @@ -456,7 +456,7 @@ def get_dicomfile(folder: Path, index: int=0) -> Path: idx = 0 for file in files: - if is_hidden(file): + if file.name.startswith('.'): LOGGER.verbose(f"Ignoring hidden file: {file}") continue if is_dicomfile(file): @@ -476,13 +476,13 @@ def get_parfiles(folder: Path) -> List[Path]: :return: The filenames of the PAR-files in the folder. """ - if is_hidden(folder): + if folder.name.startswith('.'): LOGGER.verbose(f"Ignoring hidden folder: {folder}") return [] parfiles = [] for file in sorted(folder.iterdir()): - if is_hidden(file): + if file.name.startswith('.'): LOGGER.verbose(f"Ignoring hidden file: {file}") continue if is_parfile(file): @@ -496,7 +496,7 @@ def get_datasource(session: Path, plugins: dict, recurse: int=2) -> DataSource: datasource = DataSource() for item in sorted(session.iterdir()): - if is_hidden(item): + if item.name.startswith('.'): LOGGER.verbose(f"Ignoring hidden data-source: {item}") continue if item.is_dir() and recurse: