[issue2057] difflib: add patch capability

Terry J. Reedy report at bugs.python.org
Mon Sep 20 22:58:01 CEST 2010


Terry J. Reedy <tjreedy at udel.edu> added the comment:

Given that difflib produces unified diffs (among 3 others) and that diff.py is a thin command-line wrapper that provides access to all 4 formats (with no default), I consider those two files 'ready'. So I presume you are referring to your patch.py, which is still labelled experimental.

Difflib works by analyzing sequences a and b with SequenceMatcher to produce a sequence of edits that would produce b from a. It then formats the edits into 1 of 4 formats.

Ideally, a patchlib would have a core SequenceEditor that would apply a sequence of edits (in the same format as SequenceMatcher's outputs) to sequence a to output sequence b. That much seems relatively easy. To be complete, it should also have at least 3 if not 4 parse functions that would produce edit sequences. A corresponding patch.py would then be a thin command-line wrapper over patchlib.

Your comments and a perusal of your code indicates that it has a unified diff parser, a sequence matcher, and command-line wrapper. I guess the immediate question is whether this would be enough for a start.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2057>
_______________________________________


More information about the Python-bugs-list mailing list