``~``-abbreviated, else cwd-relative, else absolute (the TS ``getRelativeMemoryPath`` shape).
(path: str, cwd: str)
| 37 | |
| 38 | |
| 39 | def _display_path(path: str, cwd: str) -> str: |
| 40 | """``~``-abbreviated, else cwd-relative, else absolute (the TS |
| 41 | ``getRelativeMemoryPath`` shape).""" |
| 42 | home = str(Path.home()) |
| 43 | real = os.path.realpath(path) |
| 44 | try: |
| 45 | rel = os.path.relpath(real, os.path.realpath(cwd)) |
| 46 | if not rel.startswith(".."): |
| 47 | return rel |
| 48 | except ValueError: |
| 49 | pass |
| 50 | if real.startswith(home + os.sep) or real == home: |
| 51 | return "~" + real[len(home):] |
| 52 | return real |
| 53 | |
| 54 | |
| 55 | def _resolve_project_memory_path(files: list, cwd: str) -> str: |
no outgoing calls