[Patches] [ python-Patches-438331 ] make ndiff.py into a library module

noreply@sourceforge.net noreply@sourceforge.net
Thu, 09 Aug 2001 11:19:18 -0700


Patches item #438331, was opened at 2001-07-03 12:59
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=438331&group_id=5470

Category: demos and tools
Group: None
>Status: Closed
>Resolution: Duplicate
Priority: 5
Submitted By: David Goodger (goodger)
Assigned to: Tim Peters (tim_one)
Summary: make ndiff.py into a library module

Initial Comment:
Here's a patch to make ndiff.py's functionality 
generally available to Python programs. It should move 
from Tools/scripts/ to Lib/.

ndiff.py's functionality is very useful for making 
comparisons human-readable. I wanted to use it from my 
Python code (unittest's of generated XML), but 
unfortunately ndiff.py wasn't written that way. So I 
refactored out the lists-of-strings comparison code 
from fcompare() into lcompare(), and parameterized the 
formerly hard-coded IS_*_JUNK filters.

I'd like to see it further converted to return a diff 
string, rather than only spew to stdout. It's easy 
enough to capture stdout, but klugey. I will do the 
mods if they have a good-to-certain chance of making 
it in. (Please let me know.)

Also, give me the word and I will whip up some TeX 
docs if Tim doesn't have the time.

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2001-08-09 11:19

Message:
Logged In: YES 
user_id=31435

I *believe* this patch is "obsoleted" by David's two later 
patches, so am closing this as Duplicate (we don't really 
have a good way to say Withdrawn or Superceded).

----------------------------------------------------------------------

Comment By: David Goodger (goodger)
Date: 2001-07-27 21:36

Message:
Logged In: YES 
user_id=7733

Submitted new patches for difflib & ndiff (http://
sourceforge.net/tracker/?func=detail&aid=445412&
group_id=5470&atid=305470), and docs (http://
sourceforge.net/tracker/?func=detail&aid=445413&
group_id=5470&atid=305470).

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-07-10 20:51

Message:
Logged In: YES 
user_id=31435

David, Guido has given his blessing to this.  Refactoring 
released functionality is too minor to require a PEP, so 
long as ndiff "still works" in the end -- all that changes 
is (I hope) that difflib grews a new capability.  Just 
don't forget the docstrings <wink>.

----------------------------------------------------------------------

Comment By: David Goodger (goodger)
Date: 2001-07-04 20:49

Message:
Logged In: YES 
user_id=7733

Tim: Your doctest example is spot-on. That's exactly 
what I'm using ndiff for, within unit tests.

I will work on a clean class to add to difflib.py, 
implementing the ndiff functionality.

PEP required? (No, I'm not going for a record.)

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-07-04 19:27

Message:
Logged In: YES 
user_id=31435

Fred, I think I understand what David's after.  ndiff has a 
great deal of logic for comparing "files" as sequences of 
lines which are in turn sequences of characters, on top of 
what difflib.py provides (in fact, only the easiest part 
was factored out).  Whether that should go into the std 
library is a legit question, though.  I'll ask Guido about 
it; if he's at all inclined to say "yes", I bet it would 
only be because he trusts me to maintain it for the rest of 
my life <0.7 wink>.  I've wanted this at times too; e.g., 
doctest would love to do a clearer job of 
showing "expected" vs "but got" outcomes than just listing 
both in full without any correlation.

David, if you want to do this you should supply a 
proper "file-like object" comparison class instead.  You 
appear to be aiming more at minimal changes here than at 
clean library design.  I'd rather see a clean new class 
added to difflib.py, the use of which could reduce ndiff.py 
to a one-pager (or so).

----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-07-03 21:26

Message:
Logged In: YES 
user_id=3066

Is this still relevant in light of ndiff being factored into
the ndiff.py script and the difflib library module?  difflib
is already documented.

Assigning to Tim since this is his baby.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=438331&group_id=5470