Yield directories starting from the given directory up to the root
(path: str)
| 250 | |
| 251 | |
| 252 | def _walk_to_root(path: str) -> Iterator[str]: |
| 253 | """ |
| 254 | Yield directories starting from the given directory up to the root |
| 255 | """ |
| 256 | if not os.path.exists(path): |
| 257 | raise IOError('Starting path not found') |
| 258 | |
| 259 | if os.path.isfile(path): |
| 260 | path = os.path.dirname(path) |
| 261 | |
| 262 | last_dir = None |
| 263 | current_dir = os.path.abspath(path) |
| 264 | while last_dir != current_dir: |
| 265 | yield current_dir |
| 266 | parent_dir = os.path.abspath(os.path.join(current_dir, os.path.pardir)) |
| 267 | last_dir, current_dir = current_dir, parent_dir |
| 268 | |
| 269 | |
| 270 | def find_dotenv( |