Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Search and replace tool that outputs a diff compatible with patch

Project Description


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

Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
sar-tool-1.0.3.tar.gz (3.6 kB) Copy SHA256 Checksum SHA256 Source May 28, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting