Get the tree structure.
(root_dir: pathlib.Path | None)
| 258 | |
| 259 | |
| 260 | def _get_folder_str(root_dir: pathlib.Path | None) -> str: |
| 261 | """Get the tree structure.""" |
| 262 | if not root_dir: |
| 263 | raise ValueError('Root dir undefined. Cannot find folder.') |
| 264 | |
| 265 | lines = epy.Lines() |
| 266 | for p in root_dir.iterdir(): |
| 267 | if p.is_dir(): |
| 268 | lines += f'{p.name}/' |
| 269 | with lines.indent(): |
| 270 | subfolder_str = _get_folder_str(p) |
| 271 | if subfolder_str: |
| 272 | lines += subfolder_str |
| 273 | else: |
| 274 | lines += p.name |
| 275 | return lines.join() |
| 276 | |
| 277 | |
| 278 | @contextlib.contextmanager |
no test coverage detected