Skip to content

Commit

Permalink
Make print_dir_tree expand ~
Browse files Browse the repository at this point in the history
  • Loading branch information
hoechenberger committed Jun 12, 2022
1 parent 2c1cdea commit 746e59b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Detailed list of changes

- :func:`~mne_bids.copyfiles.copyfile_brainvision` can now deal with ``.dat`` file extension, by `Dominik Welke`_ (:gh:`1008`)

- :func:`~mne_bids.print_dir_tree` now correctly expands ``~`` to the user's home directory, by `Richard Höchenberger`_ (:gh:`1013`)

:doc:`Find out what was new in previous releases <whats_new_previous_releases>`

.. include:: authors.rst
10 changes: 7 additions & 3 deletions mne_bids/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,9 +1174,13 @@ def print_dir_tree(folder, max_depth=None, return_str=False):
If `return_str` is ``True``, the directory tree is returned as a
string. Else, ``None`` is returned and the directory tree is printed.
"""
if not op.exists(folder):
raise ValueError('Directory does not exist: {}'.format(folder))

folder = _check_fname(
fname=folder,
overwrite='read',
must_exist=True,
name='Folder',
need_dir=True
)
max_depth = _check_max_depth(max_depth)

_validate_type(return_str, bool, 'return_str')
Expand Down

0 comments on commit 746e59b

Please sign in to comment.