List directory if exists. :param root_dir: str :return: list
(root_dir: str)
| 10 | |
| 11 | |
| 12 | def list_path(root_dir: str) -> list[str]: |
| 13 | """List directory if exists. |
| 14 | |
| 15 | :param root_dir: str |
| 16 | :return: list |
| 17 | |
| 18 | """ |
| 19 | files = [] |
| 20 | dirs = [] |
| 21 | if not os.path.isdir(root_dir): |
| 22 | return [] |
| 23 | for name in sorted(os.listdir(root_dir)): |
| 24 | if name.startswith('.'): |
| 25 | continue |
| 26 | elif os.path.isdir(name): |
| 27 | dirs.append(f'{name}/') |
| 28 | # if .sql is too restrictive it can be made configurable with some effort |
| 29 | elif name.lower().endswith('.sql'): |
| 30 | files.append(name) |
| 31 | return files + dirs |
| 32 | |
| 33 | |
| 34 | def complete_path(curr_dir: str, last_dir: str) -> str: |