Skip to content
/ sar Public

Search and replace script that outputs a diff to review and patch

Notifications You must be signed in to change notification settings

naufraghi/sar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Search and replace diff tool

PyPI version PyPI downloads GitHub license

Usage

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

Installation

$ pip install sar-tool

❗ if you install pip install sar, the script will not load correctly, because of conflicting imports.

Usage

$ sar unified_diff megasuper_diff sar.py

Searching for 'unified_diff' and replacing to 'megasuper_diff'

Processing file sar.py ... MATCH FOUND
Index: sar.py
================================================================================
--- sar.py (original)
+++ sar.py (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),
                                                      res.splitlines(1),
                                                      filename + " (original)",
                                                      filename + " (modified)")))

Licence

This script is released under the MIT licence

About

Search and replace script that outputs a diff to review and patch

Resources

Stars

Watchers

Forks

Packages

No packages published