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

Function _mdiff

tools/python-3.11.9-amd64/Lib/difflib.py:1340–1607  ·  view source on GitHub ↗

r"""Returns generator yielding marked up from/to side by side differences. Arguments: fromlines -- list of text lines to compared to tolines tolines -- list of text lines to be compared to fromlines context -- number of context lines to display on each side of difference,

(fromlines, tolines, context=None, linejunk=None,
           charjunk=IS_CHARACTER_JUNK)

Source from the content-addressed store, hash-verified

1338 return Differ(linejunk, charjunk).compare(a, b)
1339
1340def _mdiff(fromlines, tolines, context=None, linejunk=None,
1341 charjunk=IS_CHARACTER_JUNK):
1342 r"""Returns generator yielding marked up from/to side by side differences.
1343
1344 Arguments:
1345 fromlines -- list of text lines to compared to tolines
1346 tolines -- list of text lines to be compared to fromlines
1347 context -- number of context lines to display on each side of difference,
1348 if None, all from/to text lines will be generated.
1349 linejunk -- passed on to ndiff (see ndiff documentation)
1350 charjunk -- passed on to ndiff (see ndiff documentation)
1351
1352 This function returns an iterator which returns a tuple:
1353 (from line tuple, to line tuple, boolean flag)
1354
1355 from/to line tuple -- (line num, line text)
1356 line num -- integer or None (to indicate a context separation)
1357 line text -- original line text with following markers inserted:
1358 '\0+' -- marks start of added text
1359 '\0-' -- marks start of deleted text
1360 '\0^' -- marks start of changed text
1361 '\1' -- marks end of added/deleted/changed text
1362
1363 boolean flag -- None indicates context separation, True indicates
1364 either "from" or "to" line contains a change, otherwise False.
1365
1366 This function/iterator was originally developed to generate side by side
1367 file difference for making HTML pages (see HtmlDiff class for example
1368 usage).
1369
1370 Note, this function utilizes the ndiff function to generate the side by
1371 side difference markup. Optional ndiff arguments may be passed to this
1372 function and they in turn will be passed to ndiff.
1373 """
1374 import re
1375
1376 # regular expression for finding intraline change indices
1377 change_re = re.compile(r'(\++|\-+|\^+)')
1378
1379 # create the difference iterator to generate the differences
1380 diff_lines_iterator = ndiff(fromlines,tolines,linejunk,charjunk)
1381
1382 def _make_line(lines, format_key, side, num_lines=[0,0]):
1383 """Returns line of text with user's change markup and line formatting.
1384
1385 lines -- list of lines from the ndiff generator to produce a line of
1386 text from. When producing the line of text to return, the
1387 lines used are removed from this list.
1388 format_key -- '+' return first line in list with "add" markup around
1389 the entire line.
1390 '-' return first line in list with "delete" markup around
1391 the entire line.
1392 '?' return first line in list with add/delete/change
1393 intraline markup (indices obtained from second line)
1394 None return first line in list with no markup
1395 side -- indice into the num_lines list (0=from,1=to)
1396 num_lines -- from/to current line number. This is NOT intended to be a
1397 passed parameter. It is present as a keyword argument to

Callers 1

make_tableMethod · 0.85

Calls 3

ndiffFunction · 0.85
_line_pair_iteratorFunction · 0.85
compileMethod · 0.45

Tested by

no test coverage detected