pestifer.util.patch module

A simple unified diff parser and applier.

exception pestifer.util.patch.PatchApplyError[source]

Bases: Exception

pestifer.util.patch.apply_unified_diff(content: str, patch_text: str, *, reverse: bool = False) str[source]

Apply a unified diff to content and return the patched string.

  • Set reverse=True to apply the patch in reverse (like patch -R).

  • Raises PatchApplyError if context does not match.