Print a directory tree.
(root: Path, prefix: str = "", is_last: bool = True)
| 1675 | |
| 1676 | @staticmethod |
| 1677 | def _print_tree(root: Path, prefix: str = "", is_last: bool = True) -> None: |
| 1678 | """Print a directory tree.""" |
| 1679 | if prefix == "": |
| 1680 | print(f"\n{root.name}/") |
| 1681 | items = sorted(root.iterdir(), key=lambda p: (p.is_file(), p.name)) |
| 1682 | for i, item in enumerate(items): |
| 1683 | last = i == len(items) - 1 |
| 1684 | connector = "└── " if last else "├── " |
| 1685 | print(f"{prefix}{connector}{item.name}") |
| 1686 | if item.is_dir(): |
| 1687 | extension = " " if last else "│ " |
| 1688 | Splitter._print_tree(item, prefix + extension, last) |
| 1689 | |
| 1690 | |
| 1691 | # ─── Auto-Layout Generator ──────────────────────────────────────────────────── |