Skip to main content

Search and replace tool that outputs a diff compatible with patch

Project description

Description
===========

|PyPI version| |PyPI downloads| |GitHub license|

sar.py 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``

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

.. |PyPI version| image:: https://img.shields.io/pypi/v/sar-tool.svg
:target: https://pypi.python.org/pypi/sar-tool
.. |PyPI downloads| image:: https://img.shields.io/pypi/dm/sar-tool.svg
:target: https://pypi.python.org/pypi/sar-tool#downloads
.. |GitHub license| image:: https://img.shields.io/github/license/mashape/apistatus.svg
:target:

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.2.tar.gz (3.6 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for sar-tool-1.0.2.tar.gz
Algorithm Hash digest
SHA256 d58d65738dcc670f8c24bfee42560db01e2ee5d99b3baa5b4b9d4f2702da50a7
MD5 a911f2eb8ae86d5e33aa0afcb2ab68e1
BLAKE2b-256 48039537363eddbfc88ed0ae0ae1ca8b83884fc8899e5172f2e774f64f13e66d

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