(
path_or_url: str | Path,
*,
subdir: str | Path | None = None,
must_exist: bool = False,
allow_files: bool = True,
allow_dirs: bool = True,
)
| 57 | |
| 58 | |
| 59 | def resolve_outputs_path( |
| 60 | path_or_url: str | Path, |
| 61 | *, |
| 62 | subdir: str | Path | None = None, |
| 63 | must_exist: bool = False, |
| 64 | allow_files: bool = True, |
| 65 | allow_dirs: bool = True, |
| 66 | ) -> Path: |
| 67 | raw = str(path_or_url or "").strip() |
| 68 | if not raw: |
| 69 | raise HTTPException(status_code=400, detail="Output path is required") |
| 70 | |
| 71 | if raw.startswith(("http://", "https://")) and "/outputs/" not in raw: |
| 72 | raise HTTPException(status_code=400, detail="Only /outputs resources are allowed") |
| 73 | |
| 74 | normalized = _from_outputs_url(raw) |
| 75 | return ensure_outputs_subpath( |
| 76 | normalized, |
| 77 | subdir=subdir, |
| 78 | must_exist=must_exist, |
| 79 | allow_files=allow_files, |
| 80 | allow_dirs=allow_dirs, |
| 81 | ) |
| 82 | |
| 83 | |
| 84 | def _is_local_host(host: str | None) -> bool: |
no test coverage detected