[Docstring-checkins] CVS: dps/test difflib.py,NONE,1.1
Status: Pre-Alpha
Brought to you by:
goodger
From: David G. <go...@us...> - 2002-01-28 02:21:57
|
Update of /cvsroot/docstring/dps/test In directory usw-pr-cvs1:/tmp/cvs-serv11581/dps/test Added Files: difflib.py Log Message: Pre-Python2.2 version as required by tests. --- NEW FILE: difflib.py --- #! /usr/bin/env python """ Module difflib -- helpers for computing deltas between objects. Function get_close_matches(word, possibilities, n=3, cutoff=0.6): Use SequenceMatcher to return list of the best "good enough" matches. Function ndiff(a, b): Return a delta: the difference between `a` and `b` (lists of strings). Function restore(delta, which): Return one of the two sequences that generated an ndiff delta. Class SequenceMatcher: A flexible class for comparing pairs of sequences of any type. Class Differ: For producing human-readable deltas from sequences of lines of text. [...1050 lines suppressed...] emu """ try: tag = {1: "- ", 2: "+ "}[int(which)] except KeyError: raise ValueError, ('unknown delta choice (must be 1 or 2): %r' % which) prefixes = (" ", tag) results = [] for line in delta: if line[:2] in prefixes: results.append(line[2:]) return results def _test(): import doctest, difflib return doctest.testmod(difflib) if __name__ == "__main__": _test() |