diff options
author | Philip Jenvey <pjenvey@underboss.org> | 2012-10-01 19:53:43 (GMT) |
---|---|---|
committer | Philip Jenvey <pjenvey@underboss.org> | 2012-10-01 19:53:43 (GMT) |
commit | 4993cc0a5b34dc91da2b41c50e33d809f0191355 (patch) | |
tree | 5f4a1327469a43d4bbaa876e13e22a316731775d /Lib/difflib.py | |
parent | 075bbb176f69e3da013e39d847caaea9b0cee334 (diff) | |
download | cpython-4993cc0a5b34dc91da2b41c50e33d809f0191355.zip cpython-4993cc0a5b34dc91da2b41c50e33d809f0191355.tar.gz cpython-4993cc0a5b34dc91da2b41c50e33d809f0191355.tar.bz2 |
utilize yield from
Diffstat (limited to 'Lib/difflib.py')
-rw-r--r-- | Lib/difflib.py | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/Lib/difflib.py b/Lib/difflib.py index ae377d7..db5f82e 100644 --- a/Lib/difflib.py +++ b/Lib/difflib.py @@ -922,8 +922,7 @@ class Differ: else: raise ValueError('unknown tag %r' % (tag,)) - for line in g: - yield line + yield from g def _dump(self, tag, x, lo, hi): """Generate comparison results for a same-tagged range.""" @@ -942,8 +941,7 @@ class Differ: second = self._dump('+', b, blo, bhi) for g in first, second: - for line in g: - yield line + yield from g def _fancy_replace(self, a, alo, ahi, b, blo, bhi): r""" @@ -997,8 +995,7 @@ class Differ: # no non-identical "pretty close" pair if eqi is None: # no identical pair either -- treat it as a straight replace - for line in self._plain_replace(a, alo, ahi, b, blo, bhi): - yield line + yield from self._plain_replace(a, alo, ahi, b, blo, bhi) return # no close pair, but an identical pair -- synch up on that best_i, best_j, best_ratio = eqi, eqj, 1.0 @@ -1010,8 +1007,7 @@ class Differ: # identical # pump out diffs from before the synch point - for line in self._fancy_helper(a, alo, best_i, b, blo, best_j): - yield line + yield from self._fancy_helper(a, alo, best_i, b, blo, best_j) # do intraline marking on the synch pair aelt, belt = a[best_i], b[best_j] @@ -1033,15 +1029,13 @@ class Differ: btags += ' ' * lb else: raise ValueError('unknown tag %r' % (tag,)) - for line in self._qformat(aelt, belt, atags, btags): - yield line + yield from self._qformat(aelt, belt, atags, btags) else: # the synch pair is identical yield ' ' + aelt # pump out diffs from after the synch point - for line in self._fancy_helper(a, best_i+1, ahi, b, best_j+1, bhi): - yield line + yield from self._fancy_helper(a, best_i+1, ahi, b, best_j+1, bhi) def _fancy_helper(self, a, alo, ahi, b, blo, bhi): g = [] @@ -1053,8 +1047,7 @@ class Differ: elif blo < bhi: g = self._dump('+', b, blo, bhi) - for line in g: - yield line + yield from g def _qformat(self, aline, bline, atags, btags): r""" |