MCPcopy Index your code
hub / github.com/python/cpython / ndiff

Function ndiff

Lib/difflib.py:1324–1359  ·  view source on GitHub ↗

r""" Compare `a` and `b` (lists of strings); return a `Differ`-style delta. Optional keyword parameters `linejunk` and `charjunk` are for filter functions, or can be None: - linejunk: A function that should accept a single string argument and return true iff the string is jun

(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK)

Source from the content-addressed store, hash-verified

1322 yield line.encode('ascii', 'surrogateescape')
1323
1324def ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK):
1325 r"""
1326 Compare `a` and `b` (lists of strings); return a `Differ`-style delta.
1327
1328 Optional keyword parameters `linejunk` and `charjunk` are for filter
1329 functions, or can be None:
1330
1331 - linejunk: A function that should accept a single string argument and
1332 return true iff the string is junk. The default is None, and is
1333 recommended; the underlying SequenceMatcher class has an adaptive
1334 notion of "noise" lines.
1335
1336 - charjunk: A function that accepts a character (string of length
1337 1), and returns true iff the character is junk. The default is
1338 the module-level function IS_CHARACTER_JUNK, which filters out
1339 whitespace characters (a blank or tab; note: it's a bad idea to
1340 include newline in this!).
1341
1342 Tools/scripts/ndiff.py is a command-line front-end to this function.
1343
1344 Example:
1345
1346 >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True),
1347 ... 'ore\ntree\nemu\n'.splitlines(keepends=True))
1348 >>> print(''.join(diff), end="")
1349 - one
1350 ? ^
1351 + ore
1352 ? ^
1353 - two
1354 - three
1355 ? -
1356 + tree
1357 + emu
1358 """
1359 return Differ(linejunk, charjunk).compare(a, b)
1360
1361def _mdiff(fromlines, tolines, context=None, linejunk=None,
1362 charjunk=IS_CHARACTER_JUNK):

Callers 1

_mdiffFunction · 0.85

Calls 2

DifferClass · 0.85
compareMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…