Skip to main content

Search and replace tool that outputs a diff compatible with patch

Project description


PyPI version PyPI downloads GitHub license

sar is a simple search and replace script that outputs a valid diff file for review and later apply with patch.


$ pip install sar-tool


$ sar unified_diff megasuper_diff

Searching for 'unified_diff' and replacing to 'megasuper_diff'

Processing file ... MATCH FOUND
--- (original)
+++ (modified)
@@ -88,7 +88,7 @@
             debug("MATCH FOUND\n")
             print "Index:", filename
             print "=" * 80
-            diff = ''.join(list(difflib.unified_diff(orig.splitlines(1),
+            diff = ''.join(list(difflib.megasuper_diff(orig.splitlines(1),
                                                      filename + " (original)",
                                                      filename + " (modified)")))


This script is released under the MIT licence

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sar-tool, version 1.0.3
Filename, size File type Python version Upload date Hashes
Filename, size sar-tool-1.0.3.tar.gz (3.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page