eric6/Documentation/Source/eric6.UI.DiffDialog.html

changeset 7776
4a8edf69dd64
parent 7273
391d6b7b1eff
child 7989
a21d673a8f99
equal deleted inserted replaced
7775:4a1db75550bd 7776:4a8edf69dd64
44 </tr> 44 </tr>
45 </table> 45 </table>
46 <h3>Functions</h3> 46 <h3>Functions</h3>
47 47
48 <table> 48 <table>
49 49 <tr><td>None</td></tr>
50 <tr>
51 <td><a href="#context_diff">context_diff</a></td>
52 <td>Compare two sequences of lines; generate the delta as a context diff.</td>
53 </tr>
54 <tr>
55 <td><a href="#unified_diff">unified_diff</a></td>
56 <td>Compare two sequences of lines; generate the delta as a unified diff.</td>
57 </tr>
58 </table> 50 </table>
59 <hr /> 51 <hr />
60 <hr /> 52 <hr />
61 <a NAME="DiffDialog" ID="DiffDialog"></a> 53 <a NAME="DiffDialog" ID="DiffDialog"></a>
62 <h2>DiffDialog</h2> 54 <h2>DiffDialog</h2>
350 flag indicating, whether the event was handled (boolean) 342 flag indicating, whether the event was handled (boolean)
351 </dd> 343 </dd>
352 </dl> 344 </dl>
353 <div align="right"><a href="#top">Up</a></div> 345 <div align="right"><a href="#top">Up</a></div>
354 <hr /> 346 <hr />
355 <hr />
356 <a NAME="context_diff" ID="context_diff"></a>
357 <h2>context_diff</h2>
358 <b>context_diff</b>(<i>a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'</i>)
359
360 <p>
361 Compare two sequences of lines; generate the delta as a context diff.
362 </p>
363 <p>
364 Context diffs are a compact way of showing line changes and a few
365 lines of context. The number of context lines is set by 'n' which
366 defaults to three.
367 </p>
368 <p>
369 By default, the diff control lines (those with *** or ---) are
370 created with a trailing newline. This is helpful so that inputs
371 created from file.readlines() result in diffs that are suitable for
372 file.writelines() since both the inputs and outputs have trailing
373 newlines.
374 </p>
375 <p>
376 For inputs that do not have trailing newlines, set the lineterm
377 argument to "" so that the output will be uniformly newline free.
378 </p>
379 <p>
380 The context diff format normally has a header for filenames and
381 modification times. Any or all of these may be specified using
382 strings for 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
383 The modification times are normally expressed in the format returned
384 by time.ctime(). If not specified, the strings default to blanks.
385 </p>
386 <p>
387 Example:
388 </p>
389 <p>
390 <pre>
391 &gt;&gt;&gt; print ''.join(
392 ... context_diff('one\ntwo\nthree\nfour\n'.splitlines(1),
393 ... 'zero\none\ntree\nfour\n'.splitlines(1), 'Original', 'Current',
394 ... 'Sat Jan 26 23:30:50 1991', 'Fri Jun 06 10:22:46 2003')),
395 *** Original Sat Jan 26 23:30:50 1991
396 --- Current Fri Jun 06 10:22:46 2003
397 ***************
398 *** 1,4 ****
399 one
400 ! two
401 ! three
402 four
403 --- 1,4 ----
404 + zero
405 one
406 ! tree
407 four
408 </pre>
409 </p>
410 <dl>
411
412 <dt><i>a</i></dt>
413 <dd>
414 first sequence of lines (list of strings)
415 </dd>
416 <dt><i>b</i></dt>
417 <dd>
418 second sequence of lines (list of strings)
419 </dd>
420 <dt><i>fromfile</i></dt>
421 <dd>
422 filename of the first file (string)
423 </dd>
424 <dt><i>tofile</i></dt>
425 <dd>
426 filename of the second file (string)
427 </dd>
428 <dt><i>fromfiledate</i></dt>
429 <dd>
430 modification time of the first file (string)
431 </dd>
432 <dt><i>tofiledate</i></dt>
433 <dd>
434 modification time of the second file (string)
435 </dd>
436 <dt><i>n</i></dt>
437 <dd>
438 number of lines of context (integer)
439 </dd>
440 <dt><i>lineterm</i></dt>
441 <dd>
442 line termination string (string)
443 </dd>
444 </dl>
445 <dl>
446 <dt>Returns:</dt>
447 <dd>
448 a generator yielding lines of differences
449 </dd>
450 </dl>
451 <div align="right"><a href="#top">Up</a></div>
452 <hr />
453 <hr />
454 <a NAME="unified_diff" ID="unified_diff"></a>
455 <h2>unified_diff</h2>
456 <b>unified_diff</b>(<i>a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'</i>)
457
458 <p>
459 Compare two sequences of lines; generate the delta as a unified diff.
460 </p>
461 <p>
462 Unified diffs are a compact way of showing line changes and a few
463 lines of context. The number of context lines is set by 'n' which
464 defaults to three.
465 </p>
466 <p>
467 By default, the diff control lines (those with ---, +++, or @@) are
468 created with a trailing newline. This is helpful so that inputs
469 created from file.readlines() result in diffs that are suitable for
470 file.writelines() since both the inputs and outputs have trailing
471 newlines.
472 </p>
473 <p>
474 For inputs that do not have trailing newlines, set the lineterm
475 argument to "" so that the output will be uniformly newline free.
476 </p>
477 <p>
478 The unidiff format normally has a header for filenames and modification
479 times. Any or all of these may be specified using strings for
480 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'. The modification
481 times are normally expressed in the format returned by time.ctime().
482 </p>
483 <p>
484 Example:
485 </p>
486 <p>
487 <pre>
488 &gt;&gt;&gt; for line in unified_diff('one two three four'.split(),
489 ... 'zero one tree four'.split(), 'Original', 'Current',
490 ... 'Sat Jan 26 23:30:50 1991', 'Fri Jun 06 10:20:52 2003',
491 ... lineterm=''):
492 ... print line
493 --- Original Sat Jan 26 23:30:50 1991
494 +++ Current Fri Jun 06 10:20:52 2003
495 @ -1,4 +1,4 @@
496 +zero
497 one
498 -two
499 -three
500 +tree
501 four
502 </pre>
503 </p>
504 <dl>
505
506 <dt><i>a</i></dt>
507 <dd>
508 first sequence of lines (list of strings)
509 </dd>
510 <dt><i>b</i></dt>
511 <dd>
512 second sequence of lines (list of strings)
513 </dd>
514 <dt><i>fromfile</i></dt>
515 <dd>
516 filename of the first file (string)
517 </dd>
518 <dt><i>tofile</i></dt>
519 <dd>
520 filename of the second file (string)
521 </dd>
522 <dt><i>fromfiledate</i></dt>
523 <dd>
524 modification time of the first file (string)
525 </dd>
526 <dt><i>tofiledate</i></dt>
527 <dd>
528 modification time of the second file (string)
529 </dd>
530 <dt><i>n</i></dt>
531 <dd>
532 number of lines of context (integer)
533 </dd>
534 <dt><i>lineterm</i></dt>
535 <dd>
536 line termination string (string)
537 </dd>
538 </dl>
539 <dl>
540 <dt>Returns:</dt>
541 <dd>
542 a generator yielding lines of differences
543 </dd>
544 </dl>
545 <div align="right"><a href="#top">Up</a></div>
546 <hr />
547 </body></html> 347 </body></html>

eric ide

mercurial