Call path.assert_is_directory before walking.

master
voussoir 2021-12-02 19:32:39 -08:00
parent 19afbc2105
commit 23fe4d1d1e
No known key found for this signature in database
GPG Key ID: 5F7554F8C26DACCB
1 changed files with 4 additions and 0 deletions

View File

@ -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):