MCPcopy Index your code
hub / github.com/openai/openai-agents-python / update_file

Method update_file

examples/tools/apply_patch.py:48–56  ·  view source on GitHub ↗
(self, operation: ApplyPatchOperation)

Source from the content-addressed store, hash-verified

46 return ApplyPatchResult(output=f"Created {relative}")
47
48 def update_file(self, operation: ApplyPatchOperation) -> ApplyPatchResult:
49 relative = self._relative_path(operation.path)
50 self._require_approval(operation, relative)
51 target = self._resolve(operation.path)
52 original = target.read_text(encoding="utf-8")
53 diff = operation.diff or ""
54 patched = apply_diff(original, diff)
55 target.write_text(patched, encoding="utf-8")
56 return ApplyPatchResult(output=f"Updated {relative}")
57
58 def delete_file(self, operation: ApplyPatchOperation) -> ApplyPatchResult:
59 relative = self._relative_path(operation.path)

Callers

nothing calls this directly

Calls 7

_relative_pathMethod · 0.95
_require_approvalMethod · 0.95
_resolveMethod · 0.95
apply_diffFunction · 0.90
ApplyPatchResultClass · 0.90
read_textMethod · 0.80
write_textMethod · 0.80

Tested by

no test coverage detected