Write file to filesystem.
(self, path: Path, content: str)
| 119 | ) from err |
| 120 | |
| 121 | def write(self, path: Path, content: str) -> None: |
| 122 | """Write file to filesystem.""" |
| 123 | # Ensure path is a Path object |
| 124 | path = _ensure_path(path) |
| 125 | self.ensure_parent_dirs(path) |
| 126 | try: |
| 127 | path.write_text(content, encoding="utf-8") |
| 128 | except Exception as err: |
| 129 | raise HTTPException( |
| 130 | status_code=HTTPStatus.SERVER_ERROR, |
| 131 | detail=f"Failed to save file {path}", |
| 132 | ) from err |
| 133 | |
| 134 | def exists(self, path: Path) -> bool: |
| 135 | """Check if path exists on filesystem.""" |