B ?hK@sdZdZddlZddlZddZddZdd Zd d Zd d Ze dkrej ddZ de krddl Z ddl Z e ddZe dee eZednee dS)andiff [-q] file1 file2 or ndiff (-r1 | -r2) < ndiff_output > file1_or_file2 Print a human-friendly file difference report to stdout. Both inter- and intra-line differences are noted. In the second form, recreate file1 (-r1) or file2 (-r2) on stdout, from an ndiff report on stdin. In the first form, if -q ("quiet") is not specified, the first two lines of output are -: file1 +: file2 Each remaining line begins with a two-letter code: "- " line unique to file1 "+ " line unique to file2 " " line common to both files "? " line not present in either input file Lines beginning with "? " attempt to guide the eye to intraline differences, and were not present in either input file. These lines can be confusing if the source files contain tab characters. The first file can be recovered by retaining only lines that begin with " " or "- ", and deleting those 2-character prefixes; use ndiff with -r1. The second file can be recovered similarly, but by retaining only " " and "+ " lines; use ndiff with -r2; or, on Unix, the second file can be recovered by piping the output through sed -n '/^[+ ] /s/^..//p' )rNcCs tjj}||d|tdS)Nz r)sysstderrwrite__doc__)msgoutr 8/opt/alt/python37/lib64/python3.7/Tools/scripts/ndiff.pyfail5s r c CsDyt|Stk r>}ztd|dt|Sd}~XYnXdS)Nzcouldn't open z: )openIOErrorr str)Zfnamedetailr r r fopen=srcCsbt|}t|}|r|sdS|}||}|x t||D]}t|ddqJWdS)Nr )endr)r readlinesclosedifflibZndiffprint)f1namef2namef1f2abliner r r fcompareDsrc Csddl}y||d\}}Wn,|jk rH}z tt|Sd}~XYnXd}d}}x2|D]*\}}|dkrvd}d}q\|dkr\d}|} q\W|r|rtdS|r|rtdS| dkrt| dStd St|d krtd S|\} } |rtd | td | t| | S)Nrzqr:rz-qz-rzcan't specify both -q and -rzno args allowed with -r option)12z-r value must be 1 or 2zneed 2 filename argsz-:z+:)getopterrorr rrestorelenrr) argsr#ZoptsrZnoisyZqseenZrseenZoptvalZ whichfilerrr r r mainTs<   r)cCs"ttj|}tj|dS)N)rr%rstdinrstdout writelines)ZwhichZrestoredr r r r%wsr%__main__rz-profilez ndiff.proz main(args)Ztime)r __version__rrr rrr)r%__name__argvr'ZprofileZpstatsremoveZstatfrunZStatsZstatsZ strip_dirsZ sort_statsZ print_statsr r r r /s"#