Coverage for src/extratools_core/path.py: 0%

9 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-04-07 06:52 -0700

1from pathlib import Path 

2 

3 

4def clear_dir(curr_dir: Path) -> None: 

5 """ 

6 Based on example in https://docs.python.org/3/library/pathlib.html#pathlib.Path.walk 

7 """ 

8 

9 if not curr_dir.is_dir(): 

10 raise ValueError 

11 

12 for parent, dirs, files in curr_dir.walk(top_down=False): 

13 for filename in files: 

14 (parent / filename).unlink() 

15 for dirname in dirs: 

16 (parent / dirname).rmdir()