MCPcopy Create free account
hub / github.com/OpenDCAI/Paper2Any / resolve_outputs_path

Function resolve_outputs_path

fastapi_app/utils.py:59–81  ·  view source on GitHub ↗
(
    path_or_url: str | Path,
    *,
    subdir: str | Path | None = None,
    must_exist: bool = False,
    allow_files: bool = True,
    allow_dirs: bool = True,
)

Source from the content-addressed store, hash-verified

57
58
59def 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
84def _is_local_host(host: str | None) -> bool:

Calls 2

_from_outputs_urlFunction · 0.85
ensure_outputs_subpathFunction · 0.85

Tested by

no test coverage detected