-#! /usr/bin/env python3
-
-# Module ndiff version 1.7.0
-# Released to the public domain 08-Dec-2000,
-# by Tim Peters (tim.one@home.com).
-
-# Provided as-is; use at your own risk; no warranty; no promises; enjoy!
-
-# ndiff.py is now simply a front-end to the difflib.ndiff() function.
-# Originally, it contained the difflib.SequenceMatcher class as well.
-# This completes the raiding of reusable code from this formerly
-# self-contained script.
-
"""ndiff [-q] file1 file2
or
ndiff (-r1 | -r2) < ndiff_output > file1_or_file2
sys.stdout.writelines(restored)
if __name__ == '__main__':
- args = sys.argv[1:]
- if "-profile" in args:
- import profile, pstats
- args.remove("-profile")
- statf = "ndiff.pro"
- profile.run("main(args)", statf)
- stats = pstats.Stats(statf)
- stats.strip_dirs().sort_stats('time').print_stats()
- else:
- main(args)
+ main(sys.argv[1:])
The arguments for this method are the same as those for the :meth:`make_file`
method.
- :file:`Tools/scripts/diff.py` is a command-line front-end to this class and
- contains a good example of its use.
.. function:: context_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n')
function :func:`IS_CHARACTER_JUNK`, which filters out whitespace characters (a
blank or tab; it's a bad idea to include newline in this!).
- :file:`Tools/scripts/ndiff.py` is a command-line front-end to this function.
-
>>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True),
... 'ore\ntree\nemu\n'.splitlines(keepends=True))
>>> print(''.join(diff), end="")
-----------------------------------
This example shows how to use difflib to create a ``diff``-like utility.
-It is also contained in the Python source distribution, as
-:file:`Tools/scripts/diff.py`.
-.. literalinclude:: ../../Tools/scripts/diff.py
+.. literalinclude:: ../includes/diff.py
+
+ndiff example
+-------------
+
+This example shows how to use :func:`difflib.ndiff`.
+
+.. literalinclude:: ../includes/ndiff.py