Write a file in the workspace.
(&self, py: Python<'_>, path: String, content: String)
| 2052 | |
| 2053 | /// Write a file in the workspace. |
| 2054 | fn write_file(&self, py: Python<'_>, path: String, content: String) -> PyResult<PyToolResult> { |
| 2055 | let session = self.inner.clone(); |
| 2056 | let result = py |
| 2057 | .allow_threads(move || get_runtime().block_on(session.write_file(&path, &content))) |
| 2058 | .map_err(|e| PyRuntimeError::new_err(format!("{e}")))?; |
| 2059 | |
| 2060 | Ok(PyToolResult { |
| 2061 | name: result.name, |
| 2062 | output: result.output, |
| 2063 | exit_code: result.exit_code, |
| 2064 | metadata_json: result.metadata.as_ref().map(serde_json::Value::to_string), |
| 2065 | error_kind_json: result |
| 2066 | .error_kind |
| 2067 | .as_ref() |
| 2068 | .and_then(|k| serde_json::to_string(k).ok()), |
| 2069 | }) |
| 2070 | } |
| 2071 | |
| 2072 | /// List a directory in the workspace. |
| 2073 | #[pyo3(signature = (path=None))] |
no test coverage detected