MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / save

Function save

mitmproxy/optmanager.py:608–625  ·  view source on GitHub ↗

Save to path. If the destination file exists, modify it in-place. Raises OptionsError if the existing data is corrupt.

(opts: OptManager, path: Path | str, defaults: bool = False)

Source from the content-addressed store, hash-verified

606
607
608def save(opts: OptManager, path: Path | str, defaults: bool = False) -> None:
609 """
610 Save to path. If the destination file exists, modify it in-place.
611
612 Raises OptionsError if the existing data is corrupt.
613 """
614 path = Path(path).expanduser()
615 if path.exists() and path.is_file():
616 with path.open(encoding="utf8") as f:
617 try:
618 data = f.read()
619 except UnicodeDecodeError as e:
620 raise exceptions.OptionsError(f"Error trying to modify {path}: {e}")
621 else:
622 data = ""
623
624 with path.open("w", encoding="utf8") as f:
625 serialize(opts, f, data, defaults)
626
627
628def relative_path(script_path: Path | str, *, relative_to: Path | str) -> Path:

Callers

nothing calls this directly

Calls 4

PathClass · 0.85
serializeFunction · 0.70
openMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…