(path: Path, dry_run: bool)
| 287 | |
| 288 | |
| 289 | def _remove_dir_if_empty(path: Path, dry_run: bool) -> None: |
| 290 | if not path.exists() or not path.is_dir(): |
| 291 | return |
| 292 | try: |
| 293 | if any(path.iterdir()): |
| 294 | return |
| 295 | except PermissionError: |
| 296 | return |
| 297 | if dry_run: |
| 298 | print(f" [dry-run] rmdir {path}") |
| 299 | return |
| 300 | path.rmdir() |
| 301 | print(f" Removed empty directory {path}") |
| 302 | |
| 303 | |
| 304 | # -- CLI -- |