Call path.assert_is_directory before walking.

This commit is contained in:
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

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