From 746e59bb2dce86d8870512b31c3dd2d111ee0d86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20H=C3=B6chenberger?= Date: Sun, 12 Jun 2022 14:02:44 +0200 Subject: [PATCH] Make print_dir_tree expand ~ --- doc/whats_new.rst | 2 ++ mne_bids/path.py | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/whats_new.rst b/doc/whats_new.rst index 54df44230..ace151e27 100644 --- a/doc/whats_new.rst +++ b/doc/whats_new.rst @@ -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 ` .. include:: authors.rst diff --git a/mne_bids/path.py b/mne_bids/path.py index 26ca1860f..9ba1bc277 100644 --- a/mne_bids/path.py +++ b/mne_bids/path.py @@ -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')