INNER CODE UNIT · Python
safe_path
Dsadd4/AgentFigureGallery · agentfiguregallery/server.py:58
def safe_path(root: Path, raw: str) -> Path:
path = Path(unquote(raw)).expanduser()
if not path.is_absolute():
path = root / path
path = path.resolve()
if not is_under(path, root):
raise ValueError(f"Path is outside AgentFigureGallery root: {path}")
return path
def global_preference_key(candidate: dict) -> str:
if candidate.get("global_preference_key"):
return str(candidate["global_preference_key"])
for prefix, key in [
("output", "source_output_path_rel"),
("reference", "reference_candidate_id"),
("preview", "preview_path_rel"),
("script", "script_path_rel"),