Skip to main content

expansions/get_directories.py

1import pathlib
4def get_directories_under(root="."):
5 """
6 Generates the absolute paths to every directory under ``root``.
7 """
8 root = pathlib.Path(root)
10 if root.exists() and not root.is_dir():
11 raise ValueError(f"Cannot find files under file: {root!r}")
13 if not root.is_dir():
14 raise FileNotFoundError(root)
16 for dirpath, _, _ in root.walk():
17 yield dirpath
20for p in get_directories_under():
21 {cursor}