MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / ndiff

Function ndiff

tools/python-3.11.9-amd64/Lib/difflib.py:1303–1338  ·  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

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

Source from the content-addressed store, hash-verified

1301 yield line.encode('ascii', 'surrogateescape')
1302
1303def ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK):
1304 r"""
1305 Compare `a` and `b` (lists of strings); return a `Differ`-style delta.
1306
1307 Optional keyword parameters `linejunk` and `charjunk` are for filter
1308 functions, or can be None:
1309
1310 - linejunk: A function that should accept a single string argument and
1311 return true iff the string is junk. The default is None, and is
1312 recommended; the underlying SequenceMatcher class has an adaptive
1313 notion of "noise" lines.
1314
1315 - charjunk: A function that accepts a character (string of length
1316 1), and returns true iff the character is junk. The default is
1317 the module-level function IS_CHARACTER_JUNK, which filters out
1318 whitespace characters (a blank or tab; note: it's a bad idea to
1319 include newline in this!).
1320
1321 Tools/scripts/ndiff.py is a command-line front-end to this function.
1322
1323 Example:
1324
1325 >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True),
1326 ... 'ore\ntree\nemu\n'.splitlines(keepends=True))
1327 >>> print(''.join(diff), end="")
1328 - one
1329 ? ^
1330 + ore
1331 ? ^
1332 - two
1333 - three
1334 ? -
1335 + tree
1336 + emu
1337 """
1338 return Differ(linejunk, charjunk).compare(a, b)
1339
1340def _mdiff(fromlines, tolines, context=None, linejunk=None,
1341 charjunk=IS_CHARACTER_JUNK):

Callers 1

_mdiffFunction · 0.85

Calls 2

DifferClass · 0.85
compareMethod · 0.45

Tested by

no test coverage detected