[Python-checkins] CVS: python/dist/src/Doc/lib libdifflib.tex,1.8,1.9
Tim Peters
tim_one@users.sourceforge.net
Sat, 22 Sep 2001 14:30:24 -0700
Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv24440/python/Doc/lib
Modified Files:
libdifflib.tex
Log Message:
Make difflib.ndiff() and difflib.Differ.compare() generators. This
restores the 2.1 ability of Tools/scripts/ndiff.py to start producing
output before the entire comparison is complete.
Index: libdifflib.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdifflib.tex,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** libdifflib.tex 2001/08/13 19:31:59 1.8
--- libdifflib.tex 2001/09/22 21:30:22 1.9
***************
*** 33,37 ****
\begin{classdesc*}{Differ}
This is a class for comparing sequences of lines of text, and
! producing human-readable differences or deltas. Differ uses
\class{SequenceMatcher} both to compare sequences of lines, and to
compare sequences of characters within similar (near-matching)
--- 33,37 ----
\begin{classdesc*}{Differ}
This is a class for comparing sequences of lines of text, and
! producing human-readable differences or deltas. Differ uses
\class{SequenceMatcher} both to compare sequences of lines, and to
compare sequences of characters within similar (near-matching)
***************
*** 86,90 ****
charjunk}}}
Compare \var{a} and \var{b} (lists of strings); return a
! \class{Differ}-style delta.
Optional keyword parameters \var{linejunk} and \var{charjunk} are
--- 86,90 ----
charjunk}}}
Compare \var{a} and \var{b} (lists of strings); return a
! \class{Differ}-style delta (a generator generating the delta lines).
Optional keyword parameters \var{linejunk} and \var{charjunk} are
***************
*** 110,119 ****
>>> print ''.join(diff),
- one
! ? ^
+ ore
! ? ^
- two
- three
! ? -
+ tree
+ emu
--- 110,119 ----
>>> print ''.join(diff),
- one
! ? ^
+ ore
! ? ^
- two
- three
! ? -
+ tree
+ emu
***************
*** 133,136 ****
--- 133,137 ----
>>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1),
... 'ore\ntree\nemu\n'.splitlines(1))
+ >>> diff = list(diff) # materialize the generated delta into a list
>>> print ''.join(restore(diff, 1)),
one
***************
*** 227,231 ****
\method{get_longest_match()} returns \code{(\var{i}, \var{j},
\var{k})} such that \code{\var{a}[\var{i}:\var{i}+\var{k}]} is equal
! to \code{\var{b}[\var{j}:\var{j}+\var{k}]}, where
\code{\var{alo} <= \var{i} <= \var{i}+\var{k} <= \var{ahi}} and
\code{\var{blo} <= \var{j} <= \var{j}+\var{k} <= \var{bhi}}.
--- 228,232 ----
\method{get_longest_match()} returns \code{(\var{i}, \var{j},
\var{k})} such that \code{\var{a}[\var{i}:\var{i}+\var{k}]} is equal
! to \code{\var{b}[\var{j}:\var{j}+\var{k}]}, where
\code{\var{alo} <= \var{i} <= \var{i}+\var{k} <= \var{ahi}} and
\code{\var{blo} <= \var{j} <= \var{j}+\var{k} <= \var{bhi}}.
***************
*** 304,308 ****
this case.}
\lineii{'insert'}{\code{\var{b}[\var{j1}:\var{j2}]} should be
! inserted at \code{\var{a}[\var{i1}:\var{i1}]}.
Note that \code{\var{i1} == \var{i2}} in this
case.}
--- 305,309 ----
this case.}
\lineii{'insert'}{\code{\var{b}[\var{j1}:\var{j2}]} should be
! inserted at \code{\var{a}[\var{i1}:\var{i1}]}.
Note that \code{\var{i1} == \var{i2}} in this
case.}
***************
*** 460,470 ****
\begin{methoddesc}{compare}{a, b}
! Compare two sequences of lines; return the resulting delta (list).
Each sequence must contain individual single-line strings ending
with newlines. Such sequences can be obtained from the
! \method{readlines()} method of file-like objects. The list returned
! is also made up of newline-terminated strings, and ready to be used
! with the \method{writelines()} method of a file-like object.
\end{methoddesc}
--- 461,472 ----
\begin{methoddesc}{compare}{a, b}
! Compare two sequences of lines, and generate the delta (a sequence
! of lines).
Each sequence must contain individual single-line strings ending
with newlines. Such sequences can be obtained from the
! \method{readlines()} method of file-like objects. The delta generated
! also consists of newline-terminated strings, ready to be printed as-is
! via the \method{writeline()} method of a file-like object.
\end{methoddesc}
***************
*** 507,511 ****
\begin{verbatim}
! >>> result = d.compare(text1, text2)
\end{verbatim}
--- 509,513 ----
\begin{verbatim}
! >>> result = list(d.compare(text1, text2))
\end{verbatim}