From 23fe4d1d1ec9283dfb7f30e5ecf38d182c727b49 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 2 Dec 2021 19:32:39 -0800 Subject: [PATCH] Call path.assert_is_directory before walking. --- voussoirkit/spinal.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/voussoirkit/spinal.py b/voussoirkit/spinal.py index 8177e4f..a8003a8 100644 --- a/voussoirkit/spinal.py +++ b/voussoirkit/spinal.py @@ -834,6 +834,9 @@ def walk( If 'flat', yield individual files and directories one by one. If 'nested', yield tuple(root, directories, files) like os.walk does, except using pathclass.Path objects for everything. + + raises pathclass.NotDirectory if the starting path is not an existing + directory. ''' if not yield_directories and not yield_files: raise ValueError('yield_directories and yield_files cannot both be False.') @@ -869,6 +872,7 @@ def walk( glob_directories = set(glob_directories) path = pathclass.Path(path) + path.assert_is_directory() path.correct_case() def handle_exclusion(whitelist, blacklist, basename, abspath):