Skip to content

Commit

Permalink
Revert using is_hidden() because root folders can be hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelzwiers committed Sep 18, 2023
1 parent 7f03568 commit 0b5c672
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions bidscoin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))])
12 changes: 6 additions & 6 deletions bidscoin/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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:
Expand Down

0 comments on commit 0b5c672

Please sign in to comment.