Split path into head and last component for the completer. Also return position where last component starts. :param root_dir: str path :return: tuple of (string, string, int)
(root_dir: str)
| 51 | |
| 52 | |
| 53 | def parse_path(root_dir: str) -> tuple[str, str, int]: |
| 54 | """Split path into head and last component for the completer. |
| 55 | |
| 56 | Also return position where last component starts. |
| 57 | |
| 58 | :param root_dir: str path |
| 59 | :return: tuple of (string, string, int) |
| 60 | |
| 61 | """ |
| 62 | base_dir, last_dir, position = "", "", 0 |
| 63 | if root_dir: |
| 64 | base_dir, last_dir = os.path.split(root_dir) |
| 65 | position = -len(last_dir) if last_dir else 0 |
| 66 | return base_dir, last_dir, position |
| 67 | |
| 68 | |
| 69 | def suggest_path(root_dir: str) -> list[str]: |