Return the path to complete that matches the last entered component. If the last entered component is ~, expanded path would not match, so return all of the available paths. :param curr_dir: str :param last_dir: str :return: str
(curr_dir: str, last_dir: str)
| 32 | |
| 33 | |
| 34 | def complete_path(curr_dir: str, last_dir: str) -> str: |
| 35 | """Return the path to complete that matches the last entered component. |
| 36 | |
| 37 | If the last entered component is ~, expanded path would not |
| 38 | match, so return all of the available paths. |
| 39 | |
| 40 | :param curr_dir: str |
| 41 | :param last_dir: str |
| 42 | :return: str |
| 43 | |
| 44 | """ |
| 45 | if not last_dir or curr_dir.startswith(last_dir): |
| 46 | return curr_dir |
| 47 | elif last_dir == "~": |
| 48 | return os.path.join(last_dir, curr_dir) |
| 49 | else: |
| 50 | return '' |
| 51 | |
| 52 | |
| 53 | def parse_path(root_dir: str) -> tuple[str, str, int]: |