Skip to main content

Search and replace tool that outputs a diff compatible with patch

Project description

Description

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

Usage

$ ./sar.py 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

Project details


Download files

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

Source Distribution

sar-tool-1.0.1.tar.gz (1.8 kB view details)

Uploaded Source

Built Distribution

sar-tool-1.0.1.linux-x86_64.tar.gz (1.7 kB view details)

Uploaded Source

File details

Details for the file sar-tool-1.0.1.tar.gz.

File metadata

  • Download URL: sar-tool-1.0.1.tar.gz
  • Upload date:
  • Size: 1.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sar-tool-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ec3603becd34dd70986c7a1940ed70e2be113882bfb090dfce8ddc46cc338023
MD5 b0280c6dee04c8a4978c655c92982989
BLAKE2b-256 6f4c84cd9e87ff6a354750703ce45d020999b6c9193cdf46359837caf9fbfe54

See more details on using hashes here.

File details

Details for the file sar-tool-1.0.1.linux-x86_64.tar.gz.

File metadata

File hashes

Hashes for sar-tool-1.0.1.linux-x86_64.tar.gz
Algorithm Hash digest
SHA256 a78389393706bb9af3758f3455caf23d7ac0d5013c279fe07b48e0069a66b825
MD5 997bf59817884917b3093f5de60dc8f6
BLAKE2b-256 920aed10825c605d6a57ddbde4ec2ed4e78d79f1d76bf36e7eb1b0fccc2ff3ec

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page