grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026ó „à¯ÅìUBãó€•Sr/SQrSSKJr SSKJr SSKJ r \"SS5r Sr "S S 5r S$S jr S r"S S5rSSKr\R""S5R$4SjrS%SjrSrS&SjrSrS&SjrSrS'SjrS\4SjrSS\4SjrSrSrSrSr "SS \!5r"CS!r#S"r$\%S#:Xa\$"5 gg)(ae Module difflib -- helpers for computing deltas between objects. Function get_close_matches(word, possibilities, n=3, cutoff=0.6): Use SequenceMatcher to return list of the best "good enough" matches. Function context_diff(a, b): For two lists of strings, return a delta in context diff format. Function ndiff(a, b): Return a delta: the difference between `a` and `b` (lists of strings). Function restore(delta, which): Return one of the two sequences that generated an ndiff delta. Function unified_diff(a, b): For two lists of strings, return a delta in unified diff format. Class SequenceMatcher: A flexible class for comparing pairs of sequences of any type. Class Differ: For producing human-readable deltas from sequences of lines of text. Class HtmlDiff: For producing HTML side by side comparison with change highlights. ) Úget_close_matchesÚndiffÚrestoreÚSequenceMatcherÚDifferÚIS_CHARACTER_JUNKÚ IS_LINE_JUNKÚ context_diffÚ unified_diffÚ diff_bytesÚHtmlDiffÚMatché)Únlargest)Ú namedtuple)Ú GenericAliasr za b sizecó"•U(aSU-U- $g)Ng@çð?©)ÚmatchesÚlengths Ú./opt/alt/python313/lib64/python3.13/difflib.pyÚ_calculate_ratior's€Þ Ø�W‰}˜vÑ%Ð%Ø ócó|•\rSrSrSrSSjrSrSrSrSr SS jr S r S r SS jr S rSrSr\"\5rSrg)ré,a‚ SequenceMatcher is a flexible class for comparing pairs of sequences of any type, so long as the sequence elements are hashable. The basic algorithm predates, and is a little fancier than, an algorithm published in the late 1980's by Ratcliff and Obershelp under the hyperbolic name "gestalt pattern matching". The basic idea is to find the longest contiguous matching subsequence that contains no "junk" elements (R-O doesn't address junk). The same idea is then applied recursively to the pieces of the sequences to the left and to the right of the matching subsequence. This does not yield minimal edit sequences, but does tend to yield matches that "look right" to people. SequenceMatcher tries to compute a "human-friendly diff" between two sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the longest *contiguous* & junk-free matching subsequence. That's what catches peoples' eyes. The Windows(tm) windiff has another interesting notion, pairing up elements that appear uniquely in each sequence. That, and the method here, appear to yield more intuitive difference reports than does diff. This method appears to be the least vulnerable to syncing up on blocks of "junk lines", though (like blank lines in ordinary text files, or maybe "

" lines in HTML files). That may be because this is the only method of the 3 that has a *concept* of "junk" . Example, comparing two strings, and considering blanks to be "junk": >>> s = SequenceMatcher(lambda x: x == " ", ... "private Thread currentThread;", ... "private volatile Thread currentThread;") >>> .ratio() returns a float in [0, 1], measuring the "similarity" of the sequences. As a rule of thumb, a .ratio() value over 0.6 means the sequences are close matches: >>> print(round(s.ratio(), 2)) 0.87 >>> If you're only interested in where the sequences match, .get_matching_blocks() is handy: >>> for block in s.get_matching_blocks(): ... print("a[%d] and b[%d] match for %d elements" % block) a[0] and b[0] match for 8 elements a[8] and b[17] match for 21 elements a[29] and b[38] match for 0 elements Note that the last tuple returned by .get_matching_blocks() is always a dummy, (len(a), len(b), 0), and this is the only case in which the last tuple element (number of elements matched) is 0. If you want to know how to change the first sequence into the second, use .get_opcodes(): >>> for opcode in s.get_opcodes(): ... print("%6s a[%d:%d] b[%d:%d]" % opcode) equal a[0:8] b[0:8] insert a[8:8] b[8:17] equal a[8:29] b[17:38] See the Differ class for a fancy human-friendly file differencer, which uses SequenceMatcher both to compare sequences of lines, and to compare sequences of characters within similar (near-matching) lines. See also function get_close_matches() in this module, which shows how simple code building on SequenceMatcher can be used to do useful work. Timing: Basic R-O is cubic time worst case and quadratic time expected case. SequenceMatcher is quadratic time for the worst case and has expected-case behavior dependent in a complicated way on how many elements the sequences have in common; best case time is linear. NcóZ•XlS=UlUlX@lUR X#5 g)a™Construct a SequenceMatcher. Optional arg isjunk is None (the default), or a one-argument function that takes a sequence element and returns true iff the element is junk. None is equivalent to passing "lambda x: 0", i.e. no elements are considered to be junk. For example, pass lambda x: x in " \t" if you're comparing lines as sequences of characters, and don't want to synch up on blanks or hard tabs. Optional arg a is the first of two sequences to be compared. By default, an empty string. The elements of a must be hashable. See also .set_seqs() and .set_seq1(). Optional arg b is the second of two sequences to be compared. By default, an empty string. The elements of b must be hashable. See also .set_seqs() and .set_seq2(). Optional arg autojunk should be set to False to disable the "automatic junk heuristic" that treats popular elements as junk (see module documentation for more information). N)ÚisjunkÚaÚbÚautojunkÚset_seqs)Úselfrrrr s rÚ__init__ÚSequenceMatcher.__init__xs)€ðvŒ ØÐˆŒ�”Ø Œ Ø � ‰ �aÕrcóH•URU5 URU5 g)zsSet the two sequences to be compared. >>> s = SequenceMatcher() >>> s.set_seqs("abcd", "bcde") >>> s.ratio() 0.75 N)Úset_seq1Úset_seq2)r"rrs rr!ÚSequenceMatcher.set_seqs¸s€ð � ‰ �aÔØ � ‰ �aÕrcóJ•XRLagXlS=UlUlg)aÝSet the first sequence to be compared. The second sequence to be compared is not changed. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.set_seq1("bcde") >>> s.ratio() 1.0 >>> SequenceMatcher computes and caches detailed information about the second sequence, so if you want to compare one sequence S against many sequences, use .set_seq2(S) once and call .set_seq1(x) repeatedly for each of the other sequences. See also set_seqs() and set_seq2(). N)rÚmatching_blocksÚopcodes)r"rs rr&ÚSequenceMatcher.set_seq1Äs$€ð* —‘Š;Ø ØŒØ.2Ð2ˆÔ˜t�|rcóx•XRLagXlS=UlUlSUlUR 5 g)aÝSet the second sequence to be compared. The first sequence to be compared is not changed. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.set_seq2("abcd") >>> s.ratio() 1.0 >>> SequenceMatcher computes and caches detailed information about the second sequence, so if you want to compare one sequence S against many sequences, use .set_seq2(S) once and call .set_seq1(x) repeatedly for each of the other sequences. See also set_seqs() and set_seq1(). N)rr*r+Ú fullbcountÚ_SequenceMatcher__chain_b)r"rs rr'ÚSequenceMatcher.set_seq2Þs5€ð* —‘Š;Ø ØŒØ.2Ð2ˆÔ˜tœ|؈ŒØ �‰Õrcón•URn0=Uln[U5H(up4URU/5nUR U5 M* [ 5=UlnURnU(aBUR5H#nU"U5(dMURU5 M% UHnX$ M [ 5=Ul n[U5n UR(aVU S:¼aOU S-S-n UR5H'upK[U 5U :”dMURU5 M) UHnX$ M ggg)NéÈédé)rÚb2jÚ enumerateÚ setdefaultÚappendÚsetÚbjunkrÚkeysÚaddÚbpopularÚlenr Úitems) r"rr5ÚiÚeltÚindicesÚjunkrÚpopularÚnÚntestÚidxss rÚ __chain_bÚSequenceMatcher.__chain_b s €ð �F‰FˆØÐˆŒ�3ä –l‰FˆAØ—n‘n S¨"Ó-ˆGØ �N‰N˜1Ö ñ#ô  ›EÐ!ˆŒ �TØ—‘ˆÞ Ø—x‘x–z�Ù˜#—;“;Ø—H‘H˜S–Mñ"ó�Ø’Hñô#&£%Ð'ˆŒ ˜Ü �‹FˆØ �=�=˜Q #›Xؘ‘H˜q‘LˆEØ ŸY™Yž[‘ �Ü�t“9˜uÕ$Ø—K‘K Ö$ñ)ó�Ø’Hòð &ˆ=rcó•URURURURR4upVpxUc [ U5nUc [ U5nXSpºn 0n /n [ X5HknU Rn0nURX^U 5H@nUU:aM UU:¼a O1U"US- S5S-=nUU'UU :”dM/UU- S-UU- S-Upºn MB Un Mm X‘:”acX£:”a^U"XjS- 5(dLXYS- XjS- :Xa<U S- U S- U S-pºn X‘:”a)X£:”a$U"XjS- 5(dXYS- XjS- :XaM<X›-U:acX«-U:a[U"XjU -5(dIXYU -XjU -:Xa9U S- n X›-U:a,X«-U:a$U"XjU -5(dXYU -XjU -:XaM9X‘:”acX£:”a^U"XjS- 5(aLXYS- XjS- :Xa<U S- U S- U S-pºn X‘:”a)X£:”a$U"XjS- 5(aXYS- XjS- :XaM<X›-U:acX«-U:a[U"XjU -5(aIXYU -XjU -:Xa9U S-n X›-U:a,X«-U:a$U"XjU -5(aXYU -XjU -:XaM9[XšU 5$)a9Find longest matching block in a[alo:ahi] and b[blo:bhi]. By default it will find the longest match in the entirety of a and b. If isjunk is not defined: Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where alo <= i <= i+k <= ahi blo <= j <= j+k <= bhi and for all (i',j',k') meeting those conditions, k >= k' i <= i' and if i == i', j <= j' In other words, of all maximal matching blocks, return one that starts earliest in a, and of all those maximal matching blocks that start earliest in a, return the one that starts earliest in b. >>> s = SequenceMatcher(None, " abcd", "abcd abcd") >>> s.find_longest_match(0, 5, 0, 9) Match(a=0, b=4, size=5) If isjunk is defined, first the longest matching block is determined as above, but with the additional restriction that no junk element appears in the block. Then that block is extended as far as possible by matching (only) junk elements on both sides. So the resulting block never matches on junk except as identical junk happens to be adjacent to an "interesting" match. Here's the same example as before, but considering blanks to be junk. That prevents " abcd" from matching the " abcd" at the tail end of the second sequence directly. Instead only the "abcd" can match, and matches the leftmost "abcd" in the second sequence: >>> s = SequenceMatcher(lambda x: x==" ", " abcd", "abcd abcd") >>> s.find_longest_match(0, 5, 0, 9) Match(a=1, b=0, size=4) If no blocks match, return (alo, blo, 0). >>> s = SequenceMatcher(None, "ab", "c") >>> s.find_longest_match(0, 2, 0, 1) Match(a=0, b=0, size=0) rr4) rrr5r:Ú __contains__r>ÚrangeÚgetr )r"ÚaloÚahiÚbloÚbhirrr5ÚisbjunkÚbestiÚbestjÚbestsizeÚj2lenÚnothingr@Új2lengetÚnewj2lenÚjÚks rÚfind_longest_matchÚ"SequenceMatcher.find_longest_match1sð€ðt"ŸV™V T§V¡V¨T¯X©X°t·z±z×7NÑ7NÐNшˆcØ ‰;Ü�a“&ˆCØ ‰;Ü�a“&ˆCØ!$¨1�hˆðˆØˆÜ�s–ˆAð—y‘yˆH؈HØ—W‘W˜Q™T 7Ö+�à�s“7ÙØ˜“8ÙÙ"*¨1¨Q©3°Ó"2°QÑ"6Ð6��H˜Q‘KØ�x•<Ø-.¨q©S°©U°A°a±C¸±E¸1 (�E¡(ñ,ðŠEñ!ð(‹k˜e›kÙ˜! !™G™*×%Ñ%Ø�a‘‰j˜A A™g™JÓ&Ø%*¨1¡W¨e°A©g°xÀ±z˜(ˆEð‹k˜e›kÙ˜! !™G™*×%Ñ%Ø�a‘‰j˜A A™g™JÕ&à‰n˜sÓ" u¡~¸Ó';Ù˜! (™NÑ+×,Ñ,Ø�h‘Ñ 1¨8¡^Ñ#4Ó4Ø ˜‰MˆHð‰n˜sÓ" u¡~¸Ó';Ù˜! (™NÑ+×,Ñ,Ø�h‘Ñ 1¨8¡^Ñ#4Õ4ð‹k˜e›kÙ�a˜a™‘j×!Ñ!Ø�a‘‰j˜A A™g™JÓ&Ø%*¨1¡W¨e°A©g°xÀ±z˜(ˆEð‹k˜e›kÙ�a˜a™‘j×!Ñ!Ø�a‘‰j˜A A™g™JÕ&à‰n˜sÓ" u¡~¸Ó';Ù�a˜h™Ñ'×(Ñ(Ø�h‘Ñ 1¨8¡^Ñ#4Ó4Ø !‘|ˆHð‰n˜sÓ" u¡~¸Ó';Ù�a˜h™Ñ'×(Ñ(Ø�h‘Ñ 1¨8¡^Ñ#4Õ4ô�U 8Ó,Ð,rcó<•URb UR$[UR5[UR5p!SUSU4/n/nU(a�UR 5upVpxUR XVXx5=upšp¼U (aWUR U 5 XY:aXz:aUR XYXz45 X›-U:a!X«-U:aUR X›-XjU -U45 U(aM�UR5 S=n =pï/nUH=unnnXß-U:XaXï-U:XaUU- nMU(aUR XÞU45 UUUpþn M? U(aUR XÞU45 UR XS45 [[[RU55UlUR$)a«Return list of triples describing matching subsequences. Each triple is of the form (i, j, n), and means that a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in i and in j. New in Python 2.5, it's also guaranteed that if (i, j, n) and (i', j', n') are adjacent triples in the list, and the second is not the last triple in the list, then i+n != i' or j+n != j'. IOW, adjacent triples never describe adjacent equal blocks. The last triple is a dummy, (len(a), len(b), 0), and is the only triple with n==0. >>> s = SequenceMatcher(None, "abxcd", "abcd") >>> list(s.get_matching_blocks()) [Match(a=0, b=0, size=2), Match(a=3, b=2, size=2), Match(a=5, b=4, size=0)] r) r*r>rrÚpopr\r8ÚsortÚlistÚmapr Ú_make)r"ÚlaÚlbÚqueuer*rNrOrPrQr@rZr[ÚxÚi1Új1Úk1Ú non_adjacentÚi2Új2Úk2s rÚget_matching_blocksÚ#SequenceMatcher.get_matching_blocks¥s“€ð& × Ñ Ñ +Ø×'Ñ'Ð 'Ü�T—V‘V“œc $§&¡&›kˆBð�R˜˜B�Ð ˆØˆÞØ!&§¡£Ñ ˆC�cØ×1Ñ1°#¸CÓEÐ E‰GˆA�!öØ×&Ñ& qÔ)Ø“7˜s›wØ—L‘L #¨#Ð!1Ô2Ø‘3˜“9 ¡ s£Ø—L‘L !¡# s¨a©C°Ð!5Ô6÷ˆeð ×ÑÔð ЈЈR؈ Û)‰JˆB��Bà‰w˜"‹} ¡¨B£ð�b‘’ö Ø ×'Ñ'¨°¨ Ô5Ø  R˜�™ñ*ö Ø × Ñ  ¨  Ô -à×јb a˜[Ô*Ü#¤C¬¯ © °\Ó$BÓCˆÔØ×#Ñ#Ð#rcó>•URb UR$S=p/=UlnUR5HcupEnSnX:aX%:aSnOX:aSnOX%:aSnU(aURXqXBU45 XF-XV-p!U(dMOURSXAXR45 Me U$)a«Return list of 5-tuples describing how to turn a into b. Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the tuple preceding it, and likewise for j1 == the previous j2. The tags are strings, with these meanings: 'replace': a[i1:i2] should be replaced by b[j1:j2] 'delete': a[i1:i2] should be deleted. Note that j1==j2 in this case. 'insert': b[j1:j2] should be inserted at a[i1:i1]. Note that i1==i2 in this case. 'equal': a[i1:i2] == b[j1:j2] >>> a = "qabxcd" >>> b = "abycdf" >>> s = SequenceMatcher(None, a, b) >>> for tag, i1, i2, j1, j2 in s.get_opcodes(): ... print(("%7s a[%d:%d] (%s) b[%d:%d] (%s)" % ... (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2]))) delete a[0:1] (q) b[0:0] () equal a[1:3] (ab) b[0:2] (ab) replace a[3:4] (x) b[2:3] (y) equal a[4:6] (cd) b[3:5] (cd) insert a[6:6] () b[5:6] (f) rÚÚreplaceÚdeleteÚinsertÚequal)r+ror8)r"r@rZÚanswerÚaiÚbjÚsizeÚtags rÚ get_opcodesÚSequenceMatcher.get_opcodesìs­€ð: �<‰<Ñ #Ø—<‘<Р؈ ˆØ "Ð"ˆŒ �vØ ×4Ñ4Ö6‰LˆB�Dð ˆCØ‹v˜!›&ؑؓؑؓØ�ÞØ— ‘  ¨¨rÐ2Ô4Ø‘7˜B™Gˆq÷ˆtØ— ‘  ¨°Ð6Ö8ñ'7ð(ˆ rc #óp# •UR5nU(dS/nUSSS:Xa+USup4pVnU[XEU- 5U[XgU- 5U4US'USSS:Xa*USup4pVnX4[XTU-5U[XvU-54US'X-n/n UHwup4pVnUS:XaVXT- U:”aNU RX4[XTU-5U[XvU-545 U v• /n [XEU- 5[XgU- 5pdU RX4XVU45 My U (a![ U 5S:Xa U SSS:XdU v• ggg7f)a9Isolate change clusters by eliminating ranges with no changes. Return a generator of groups with up to n lines of context. Each group is in the same format as returned by get_opcodes(). >>> from pprint import pprint >>> a = list(map(str, range(1,40))) >>> b = a[:] >>> b[8:8] = ['i'] # Make an insertion >>> b[20] += 'x' # Make a replacement >>> b[23:28] = [] # Make a deletion >>> b[30] += 'y' # Make another replacement >>> pprint(list(SequenceMatcher(None,a,b).get_grouped_opcodes())) [[('equal', 5, 8, 5, 8), ('insert', 8, 8, 8, 9), ('equal', 8, 11, 9, 12)], [('equal', 16, 19, 17, 20), ('replace', 19, 20, 20, 21), ('equal', 20, 22, 21, 23), ('delete', 22, 27, 23, 23), ('equal', 27, 30, 23, 26)], [('equal', 31, 34, 27, 30), ('replace', 34, 35, 30, 31), ('equal', 35, 38, 31, 34)]] )rvrr4rr4rrvéÿÿÿÿr4N)r|ÚmaxÚminr8r>) r"rEÚcodesr{rhrlrirmÚnnÚgroups rÚget_grouped_opcodesÚ#SequenceMatcher.get_grouped_opcodes#sXé€ð2× Ñ Ó"ˆÞØ*Ð+ˆEà �‰8�A‰;˜'Ó !Ø"'¨¡(Ñ ˆC�R˜RØœC  q¡D›M¨2¬s°2¸!±t«}¸bÐ@ˆE�!‰HØ �‰9�Q‰<˜7Ó "Ø"'¨¡)Ñ ˆC�R˜Rؤ R¨A©£°´C¸¸q¹D³MÐAˆE�"‰Ià ‰UˆØˆÛ#(Ñ ˆC�R˜Rð�g‹~ "¡%¨"£*Ø— ‘ ˜c¤s¨2°!©t£}°b¼#¸bÀQÁ$»-ÐHÔIØ’ Ø�ܘR A¡›¬¨B°1±« �BØ �L‰L˜# 2¨2Ð.Ö /ñ$)ö œ#˜e›* a›-¨E°!©H°Q©K¸7Ó,BØ‹Kð-Cˆ5ùs‚D4D6có¬•[SUR555n[U[UR5[UR 5-5$)aRReturn a measure of the sequences' similarity (float in [0,1]). Where T is the total number of elements in both sequences, and M is the number of matches, this is 2.0*M / T. Note that this is 1 if the sequences are identical, and 0 if they have nothing in common. .ratio() is expensive to compute if you haven't already computed .get_matching_blocks() or .get_opcodes(), in which case you may want to try .quick_ratio() or .real_quick_ratio() first to get an upper bound. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.quick_ratio() 0.75 >>> s.real_quick_ratio() 1.0 c3ó*# •UH oSv• M g7f)rNr)Ú.0Útriples rÚ Ú(SequenceMatcher.ratio..ksé€ÐJÒ/I V˜R–jÒ/Iùs‚)Úsumrorr>rr)r"rs rÚratioÚSequenceMatcher.ratioUs?€ô,ÑJ¨t×/GÑ/GÔ/IÓJÓJˆÜ ¬¨T¯V©V«´s¸4¿6¹6³{Ñ)BÓCÐCrcó¸•URc30=UlnURHnURUS5S-X'M URn0nURSpTURH;nU"U5(aX2nOURUS5nUS- X2'US:”dM6US-nM= [ U[ UR5[ UR5-5$)z‘Return an upper bound on ratio() relatively quickly. This isn't defined beyond that it is an upper bound on .ratio(), and is faster to compute. rr4)r.rrMrKrrr>)r"r.rAÚavailÚavailhasrÚnumbs rÚ quick_ratioÚSequenceMatcher.quick_rationsÉ€ð �?‰?Ñ "Ø+-Ð -ˆDŒO˜jØ—v”v�Ø",§.¡.°°aÓ"8¸1Ñ"<� “ñà—_‘_ˆ ðˆØ!×.Ñ.°�'Ø—6”6ˆCÙ˜�}‰}Ø‘z‘à!—~‘~ c¨1Ó-�Ø ™ˆE‰JØ�a�xØ! A™+’ñô  ¬¨T¯V©V«´s¸4¿6¹6³{Ñ)BÓCÐCrcó‚•[UR5[UR5p![[ X5X-5$)z²Return an upper bound on ratio() very quickly. This isn't defined beyond that it is an upper bound on .ratio(), and is faster to compute than either .ratio() or .quick_ratio(). )r>rrrr�)r"rdres rÚreal_quick_ratioÚ SequenceMatcher.real_quick_ratio‹s0€ô�T—V‘V“œc $§&¡&›kˆBô ¤ B£ ¨R©WÓ5Ð5r) rr rr5r:r=r.rr*r+)NrrrrT)rNrN)é)Ú__name__Ú __module__Ú __qualname__Ú__firstlineno__Ú__doc__r#r!r&r'r/r\ror|r…rŽr”r—Ú classmethodrÚ__class_getitem__Ú__static_attributes__rrrrr,s]†ñHôT>ò@ ò3ò4òX%ôNr-òhE$òN5ôn0òdDò2Dò: 6ñ$ LÓ1Órrcóì•US:”d[SU<35eSUs=::aS::dO [SU<35e/n[5nURU5 UHwnURU5 UR 5U:¼dM*UR 5U:¼dM@UR 5U:¼dMVURUR 5U45 My [X$5nUVVs/sHupvUPM snn$s snnf)awUse SequenceMatcher to return list of the best "good enough" matches. word is a sequence for which close matches are desired (typically a string). possibilities is a list of sequences against which to match word (typically a list of strings). Optional arg n (default 3) is the maximum number of close matches to return. n must be > 0. Optional arg cutoff (default 0.6) is a float in [0, 1]. Possibilities that don't score at least that similar to word are ignored. The best (no more than n) matches among the possibilities are returned in a list, sorted by similarity score, most similar first. >>> get_close_matches("appel", ["ape", "apple", "peach", "puppy"]) ['apple', 'ape'] >>> import keyword as _keyword >>> get_close_matches("wheel", _keyword.kwlist) ['while'] >>> get_close_matches("Apple", _keyword.kwlist) [] >>> get_close_matches("accept", _keyword.kwlist) ['except'] rzn must be > 0: grzcutoff must be in [0.0, 1.0]: ) Ú ValueErrorrr'r&r—r”rŽr8Ú _nlargest)ÚwordÚ possibilitiesrEÚcutoffÚresultÚsrgÚscores rrršsË€ð: �‹6ݲÐ3Ó4Ð4Ø �&Õ ˜CÕ ÝºvÐGÓHÐHØ €FÜÓ€A؇J�JˆtÔÛ ˆØ � ‰ �1Œ Ø × Ñ Ó  6Õ )Ø �=‰=‹?˜fÕ $Ø �7‰7‹9˜Õ Ø �M‰M˜1Ÿ7™7›9 a˜.Ö )ñ ô�qÓ !€Fá$Ô %šf‘(�%‹A™fÒ %Ð%ùÓ %sÃC0cóD•SRS[X555$)zAReplace whitespace with the original whitespace characters in `s`rrc3ód# •UH&upUS:XaUR5(aUOUv• M( g7f)Ú N)Úisspace)r‰ÚcÚtag_cs rr‹Ú$_keep_original_ws..Ís.é€ðâ%‰HˆAð�c‹\˜aŸi™iŸk™k‰¨uÔ4Ú%ùs‚.0)ÚjoinÚzip)r©Útag_ss rÚ_keep_original_wsrµËs$€à �7‰7ñä˜Aœ óó ðrcóF•\rSrSrSrS SjrSrSrSrSr S r S r S r g) riÔa© Differ is a class for comparing sequences of lines of text, and producing human-readable differences or deltas. Differ uses SequenceMatcher both to compare sequences of lines, and to compare sequences of characters within similar (near-matching) lines. Each line of a Differ delta begins with a two-letter code: '- ' line unique to sequence 1 '+ ' line unique to sequence 2 ' ' line common to both sequences '? ' line not present in either input sequence Lines beginning with '? ' attempt to guide the eye to intraline differences, and were not present in either input sequence. These lines can be confusing if the sequences contain tab characters. Note that Differ makes no claim to produce a *minimal* diff. To the contrary, minimal diffs are often counter-intuitive, because they synch up anywhere possible, sometimes accidental matches 100 pages apart. Restricting synch points to contiguous matches preserves some notion of locality, at the occasional cost of producing a longer diff. Example: Comparing two texts. First we set up the texts, sequences of individual single-line strings ending with newlines (such sequences can also be obtained from the `readlines()` method of file-like objects): >>> text1 = ''' 1. Beautiful is better than ugly. ... 2. Explicit is better than implicit. ... 3. Simple is better than complex. ... 4. Complex is better than complicated. ... '''.splitlines(keepends=True) >>> len(text1) 4 >>> text1[0][-1] '\n' >>> text2 = ''' 1. Beautiful is better than ugly. ... 3. Simple is better than complex. ... 4. Complicated is better than complex. ... 5. Flat is better than nested. ... '''.splitlines(keepends=True) Next we instantiate a Differ object: >>> d = Differ() Note that when instantiating a Differ object we may pass functions to filter out line and character 'junk'. See Differ.__init__ for details. Finally, we compare the two: >>> result = list(d.compare(text1, text2)) 'result' is a list of strings, so let's pretty-print it: >>> from pprint import pprint as _pprint >>> _pprint(result) [' 1. Beautiful is better than ugly.\n', '- 2. Explicit is better than implicit.\n', '- 3. Simple is better than complex.\n', '+ 3. Simple is better than complex.\n', '? ++\n', '- 4. Complex is better than complicated.\n', '? ^ ---- ^\n', '+ 4. Complicated is better than complex.\n', '? ++++ ^ ^\n', '+ 5. Flat is better than nested.\n'] As a single multi-line string it looks like this: >>> print(''.join(result), end="") 1. Beautiful is better than ugly. - 2. Explicit is better than implicit. - 3. Simple is better than complex. + 3. Simple is better than complex. ? ++ - 4. Complex is better than complicated. ? ^ ---- ^ + 4. Complicated is better than complex. ? ++++ ^ ^ + 5. Flat is better than nested. Ncó•XlX lg)aU Construct a text differencer, with optional filters. The two optional keyword parameters are for filter functions: - `linejunk`: A function that should accept a single string argument, and return true iff the string is junk. The module-level function `IS_LINE_JUNK` may be used to filter out lines without visible characters, except for at most one splat ('#'). It is recommended to leave linejunk None; the underlying SequenceMatcher class has an adaptive notion of "noise" lines that's better than any static definition the author has ever been able to craft. - `charjunk`: A function that should accept a string of length 1. The module-level function `IS_CHARACTER_JUNK` may be used to filter out whitespace characters (a blank or tab; **note**: bad idea to include newline in this!). Use of IS_CHARACTER_JUNK is recommended. N©ÚlinejunkÚcharjunk)r"r¹rºs rr#ÚDiffer.__init__*s€ð(!Œ Ø � rc #ót# •[URX5nUR5HˆupEpgnUS:XaURXXbXx5n O]US:XaUR SXU5n OCUS:XaUR SX'U5n O)US:XaUR SXU5n O[ SU<35eU S hv•N MŠ g N 7f) aY Compare two sequences of lines; generate the resulting delta. Each sequence must contain individual single-line strings ending with newlines. Such sequences can be obtained from the `readlines()` method of file-like objects. The delta generated also consists of newline- terminated strings, ready to be printed as-is via the writelines() method of a file-like object. Example: >>> print(''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(True), ... 'ore\ntree\nemu\n'.splitlines(True))), ... end="") - one ? ^ + ore ? ^ - two - three ? - + tree + emu rsrtÚ-ruÚ+rvr­ú unknown tag N)rr¹r|Ú_fancy_replaceÚ_dumpr£) r"rrÚcruncherr{rNrOrPrQÚgs rÚcompareÚDiffer.compareAs²é€ô4# 4§=¡=°!Ó7ˆØ'/×';Ñ';Ö'=Ñ #ˆC�c Ø�iÓØ×'Ñ'¨°¸ÓA‘ؘ“Ø—J‘J˜s A¨CÓ0‘ؘ“Ø—J‘J˜s A¨CÓ0‘ؘ“Ø—J‘J˜s A¨CÓ0‘å ²SÐ!:Ó;Ð;à�LŠLò(>ñ ùs‚B*B8Â,B6Â- B8c#óJ# •[X45HnU<SX%<3v• M g7f)z4Generate comparison results for a same-tagged range.r­N)rL)r"r{rgÚloÚhir@s rrÁÚ Differ._dumpjs é€ä�r–ˆAÛ  !£$Ð'Ô 'òùs‚!#c#óæ# •Xe- X2- :a'URSXEU5nURSXU5nO&URSXU5nURSXEU5nXx4H n U Shv•N M gN 7f)Nr¾r½)rÁ) r"rrNrOrrPrQÚfirstÚsecondrÃs rÚ_plain_replaceÚDiffer._plain_replaceosqé€ð ‰9�s‘yÓ Ø—Z‘Z  Q¨SÓ1ˆEØ—Z‘Z  Q¨SÓ1‰Fà—Z‘Z  Q¨SÓ1ˆEØ—Z‘Z  Q¨SÓ1ˆFà“ˆAØ�LŠLòÙ ùs‚A#A1Á%A/Á& A1c#ó"# •Supx[UR5n Sup«[XV5H n XLn U RU 5 [X#5HynXnXý:XaU cXìpºMU R U5 U R 5U:”dM:U R 5U:”dMPU R5U:”dMfU R5XìnnnM{ M¢ Xx:a%U cURXX4XV5Shv•N gX«SnnnOSn URXWXEW5Shv•N UUUUnnU c·S=nnU RUU5 U R5HpunnnnnUU- UU- nnUS:XaUSU-- nUSU-- nM+US:Xa US U-- nM;US :Xa US U-- nMKUS :XaUS U-- nUS U-- nMc[SU<35e URUUUU5Shv•N OSU-v• URUUS-X4US-U5Shv•N gGNNöN5N 7f)aÜ When replacing one block of lines with another, search the blocks for *similar* lines; the best-matching pair (if any) is used as a synch point, and intraline difference marking is done on the similar pair. Lots of work, but often worth it. Example: >>> d = Differ() >>> results = d._fancy_replace(['abcDefghiJkl\n'], 0, 1, ... ['abcdefGhijkl\n'], 0, 1) >>> print(''.join(results), end="") - abcDefghiJkl ? ^ ^ ^ + abcdefGhijkl ? ^ ^ ^ )g®Gáz®ç?gè?©NNNrrrrsÚ^rtr½rur¾rvr­r¿ú r4)rrºrLr'r&r—r”rŽrÍÚ _fancy_helperr!r|r£Ú_qformat)r"rrNrOrrPrQÚ best_ratior§rÂÚeqiÚeqjrZryr@rxÚbest_iÚbest_jÚaeltÚbeltÚatagsÚbtagsr{Úai1Úai2Úbj1Úbj2rdres rrÀÚDiffer._fancy_replace}sbé€ð*(ш Ü" 4§=¡=Ó1ˆØ‰ˆô �s–ˆAØ‘ˆBØ × Ñ ˜bÔ !ܘ3–_�Ø‘T�Ø“8Ø‘{Ø#$˜SÙØ×!Ñ! "Ô%ð×,Ñ,Ó.°Õ;Ø×*Ñ*Ó,¨zÕ9Ø—n‘nÓ&¨Õ3Ø19·±Ó1AÀ1¨ �J©ó!%ñ!ð( Ó à‰{à×.Ñ.¨q°s¸sÓH×HÐHØà),°3˜J�FˆF˜JðˆCð ×%Ñ% a¨f°a¸fÓE×EÐEð�v‘Y  &¡ ˆdˆØ ‰;àÐ ˆE�EØ × Ñ ˜d DÔ )Ø+3×+?Ñ+?Ö+AÑ'��S˜#˜s Cؘs™ C¨#¡I�B�ؘ)Ó#ؘS 2™XÑ%�EؘS 2™XÑ%’EؘH“_ؘS 2™XÑ%’EؘH“_ؘS 2™XÑ%’EؘG“^ؘS 2™XÑ%�EؘS 2™XÑ%’Eå$ºÐ%>Ó?Ð?ñ,Bð—}‘} T¨4°¸Ó>× >Ñ >ð˜‘+Ò ð×%Ñ% a¨°©°3¸6À!¹8ÀSÓI×IÑIòQIñ Fñ, ?ñ Jùs[‚BHÂHÂHÂ49HÃ-HÃ.$HÄH ÄCHÇH Ç*HÈH ÈHÈ HÈ HÈ Hc#ó¼# •/nX#:a-XV:aURXX4XV5nO,URSXU5nOXV:aURSXEU5nUShv•N gN7f)Nr½r¾)rÀrÁ)r"rrNrOrrPrQrÃs rrÓÚDiffer._fancy_helperÛsX逨 ˆØ ‹9Ø‹yØ×'Ñ'¨°¸ÓA‘à—J‘J˜s A¨CÓ0‘Ø ‹YØ— ‘ ˜3 ¨Ó,ˆAà� ‹ ùs‚AAÁAÁAc#óÊ# •[X5R5n[X$5R5nSU-v• U(aSUS3v• SU-v• U(a SUS3v• gg7f)a: Format "?" output and deal with tabs. Example: >>> d = Differ() >>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n', ... ' ^ ^ ^ ', ' ^ ^ ^ ') >>> for line in results: print(repr(line)) ... '- \tabcDefghiJkl\n' '? \t ^ ^ ^\n' '+ \tabcdefGhijkl\n' '? \t ^ ^ ^\n' ú- z? Ú ú+ N)rµÚrstrip)r"ÚalineÚblinerÜrÝs rrÔÚDiffer._qformatçshé€ô " %Ó/×6Ñ6Ó8ˆÜ! %Ó/×6Ñ6Ó8ˆà�U‰lÒÞ Ø�u�g˜R�.Ò à�U‰lÒÞ Ø�u�g˜R�.Ó ð ùs‚A!A#)rºr¹rÐ) ršr›rœr�ržr#rÄrÁrÍrÀrÓrÔr¡rrrrrÔs0†ñSôj!ò.'òR(ò ò\Jò| õ!rrNz \s*(?:#\s*)?$có•U"U5SL$)z» Return True for ignorable line: iff `line` is blank or contains a single '#'. Examples: >>> IS_LINE_JUNK('\n') True >>> IS_LINE_JUNK(' # \n') True >>> IS_LINE_JUNK('hello\n') False Nr)ÚlineÚpats rrrs€ñ ˆt‹9˜DÐ Ð rcó •X;$)zÒ Return True for ignorable character: iff `ch` is a space or tab. Examples: >>> IS_CHARACTER_JUNK(' ') True >>> IS_CHARACTER_JUNK('\t') True >>> IS_CHARACTER_JUNK('\n') False >>> IS_CHARACTER_JUNK('x') False r)ÚchÚwss rrr%s €ð ‰8€Orcó|•US-nX- nUS:XaSRU5$U(dUS-nSRX#5$©z Convert range to the "ed" formatr4z{}z{},{}©Úformat©ÚstartÚstopÚ beginningrs rÚ_format_range_unifiedrû<sE€ð˜‘ €IØ ‰\€FØ �ƒ{Ø�{‰{˜9Ó%Ð%Þ Ø�Q‰ˆ Ø �>‰>˜)Ó ,Ð,rc #ó|# •[XX#XEU5 Sn[SX5RU5GHn U(d^SnU(aSRU5OSn U(aSRU5OSn SRX*U5v• SRX;U5v• U SU S pÜ[ U S U S 5n[ U S U S 5nSRXïU5v• U HXunnnnnUS:XaUUUH nSU-v• M M$US;aUUUH nSU-v• M US;dMEUUUH nSU-v• M MZ GM g7f)a. Compare two sequences of lines; generate the delta as a unified diff. Unified diffs are a compact way of showing line changes and a few lines of context. The number of context lines is set by 'n' which defaults to three. By default, the diff control lines (those with ---, +++, or @@) are created with a trailing newline. This is helpful so that inputs created from file.readlines() result in diffs that are suitable for file.writelines() since both the inputs and outputs have trailing newlines. For inputs that do not have trailing newlines, set the lineterm argument to "" so that the output will be uniformly newline free. The unidiff format normally has a header for filenames and modification times. Any or all of these may be specified using strings for 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'. The modification times are normally expressed in the ISO 8601 format. Example: >>> for line in unified_diff('one two three four'.split(), ... 'zero one tree four'.split(), 'Original', 'Current', ... '2005-01-26 23:30:50', '2010-04-02 10:20:52', ... lineterm=''): ... print(line) # doctest: +NORMALIZE_WHITESPACE --- Original 2005-01-26 23:30:50 +++ Current 2010-04-02 10:20:52 @@ -1,4 +1,4 @@ +zero one -two -three +tree four FNTú {}rrú --- {}{}{}z +++ {}{}{}rrr4ér™éz@@ -{} +{} @@{}rvr­>rtrsr½>rursr¾)Ú _check_typesrr…rörû)rrÚfromfileÚtofileÚ fromfiledateÚ tofiledaterEÚlinetermÚstartedr„ÚfromdateÚtodaterËÚlastÚ file1_rangeÚ file2_ranger{rhrlrirmrîs rr r GsSé€ôR��x¨À8ÔLØ€GÜ   aÓ*×>Ñ>¸q×AˆÞ؈GÞ6B�v—}‘} \Ô2ȈHÞ2<�V—]‘] :Ô.À"ˆFØ×%Ñ% h¸(ÓCÒ CØ×%Ñ% f°hÓ?Ò ?à˜A‘h  b¡ ˆtÜ+¨E°!©H°d¸1±gÓ>ˆ Ü+¨E°!©H°d¸1±gÓ>ˆ Ø×&Ñ& {ÀÓJÒJã#(Ñ ˆC��R˜˜RØ�g‹~ؘb ›H�DØ ™*Ô$ñ%áØÐ+Ó+ؘb ›H�DØ ™*Ô$ñ%àÐ+Õ+ؘb ›H�DØ ™*Ô$ó%ô$)òBùs ‚DD<ÄD<cóˆ•US-nX- nU(dUS-nUS::aSRU5$SRX"U-S- 5$rôrõr÷s rÚ_format_range_contextr�sO€ð˜‘ €IØ ‰\€FÞ Ø�Q‰ˆ Ø �ƒ{Ø�{‰{˜9Ó%Ð%Ø �>‰>˜)°Ñ%7¸!Ñ%;Ó <Ð>> print(''.join(context_diff('one\ntwo\nthree\nfour\n'.splitlines(True), ... 'zero\none\ntree\nfour\n'.splitlines(True), 'Original', 'Current')), ... end="") *** Original --- Current *************** *** 1,4 **** one ! two ! three four --- 1,4 ---- + zero one ! tree four rèræz! rÒ)rurtrsrvFNTrýrrz *** {}{}{}rþrrz***************r4rÿz *** {} ****{}c3ó6# •UHun o!S;v• M g7f)>rtrsNr©r‰r{Ú_s rr‹Úcontext_diff..Ùóé€ÐIÂ5±°°Q¸¸1¸aÐ+Ö+Â5ùó‚rur™rz --- {} ----{}c3ó6# •UHun o!S;v• M g7f)>rursNrrs rr‹rârrrt)rÚdictrr…rörÚany)rrrrrrrErÚprefixrr„rr rËr r r{rhrlrrîr rirms rr r œsšé€ôX��x¨À8ÔLÜ ˜ d°DÀÑ E€FØ€GÜ   aÓ*×>Ñ>¸q×AˆÞ؈GÞ6B�v—}‘} \Ô2ȈHÞ2<�V—]‘] :Ô.À"ˆFØ×%Ñ% h¸(ÓCÒ CØ×%Ñ% f°hÓ?Ò ?à˜A‘h  b¡ ˆtØ (Ñ*Ò*ä+¨E°!©H°d¸1±gÓ>ˆ Ø×$Ñ$ [Ó;Ò;ä ÑIÁ5ÓI× IÑ IÛ%*Ñ!��R˜˜Q Ø˜(•?Ø ! " R£˜Ø$ S™k¨DÑ0Ô0ó!)ñ&+ô ,¨E°!©H°d¸1±gÓ>ˆ Ø×$Ñ$ [°(Ó;Ò;ä ÑIÁ5ÓI× IÔ IÛ%*Ñ!��Q˜˜2˜rؘ(•?Ø ! " R£˜Ø$ S™k¨DÑ0Ô0ó!)ô&+ò1Bùs‚C.decodesK€ð *Ø—8‘8˜GÐ%6Ó7Ð 7øÜô *䘓G×$Ô$£að)ˆCä˜C“. cÐ )ûð *ús‚” A ž*AÁA r%r&N)rarbÚencode) ÚdfuncrrrrrrrErr'Úlinesrîs rr r ùs…é€ò*ô ŒS�‹^Ó€AÜ ŒS�‹^Ó€AÙ�hÓ€HÙ �F‹^€FÙ˜,Ó'€LÙ˜ Ó#€JÙ�hÓ€Há �!˜¨,ÀAÓ P€EÛˆØ�k‰k˜'Ð#4Ó5Ô5òùs‚A=A?có6•[X#5RX5$)aÞ 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 junk. The default is None, and is recommended; the underlying SequenceMatcher class has an adaptive notion of "noise" lines. - charjunk: A function that accepts a character (string of length 1), and returns true iff the character is junk. The default is the module-level function IS_CHARACTER_JUNK, which filters out whitespace characters (a blank or tab; note: it's a bad idea to include newline in this!). Tools/scripts/ndiff.py is a command-line front-end to this function. Example: >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True), ... 'ore\ntree\nemu\n'.splitlines(keepends=True)) >>> print(''.join(diff), end="") - one ? ^ + ore ? ^ - two - three ? - + tree + emu )rrÄ)rrr¹rºs rrrs€ôF �(Ó %× -Ñ -¨aÓ 3Ð3rc#óN^^^^# •SSKnUR"S5m[XX45mSS/4U4SjjmUU4SjmU4SjnU"5nUc UShv•N gUS- nSnSS/U-p©Sn U SLa%[U5upÍn X’-nXÍU 4X®'U S- n U SLaM%X’:”aS v• UnOU nSn U(aX’-nU S- n X®v• US-nU(aMUS- nU(a/[U5upÍn U (aUS- nOUS-nXÍU 4v• U(aM/M¥N²![a gf=f![a gf=f7f) a{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, if None, all from/to text lines will be generated. linejunk -- passed on to ndiff (see ndiff documentation) charjunk -- passed on to ndiff (see ndiff documentation) This function returns an iterator which returns a tuple: (from line tuple, to line tuple, boolean flag) from/to line tuple -- (line num, line text) line num -- integer or None (to indicate a context separation) line text -- original line text with following markers inserted: '\0+' -- marks start of added text '\0-' -- marks start of deleted text '\0^' -- marks start of changed text '\1' -- marks end of added/deleted/changed text boolean flag -- None indicates context separation, True indicates either "from" or "to" line contains a change, otherwise False. This function/iterator was originally developed to generate side by side file difference for making HTML pages (see HtmlDiff class for example usage). Note, this function utilizes the ndiff function to generate the side by side difference markup. Optional ndiff arguments may be passed to this function and they in turn will be passed to ndiff. rNz (\++|\-+|\^+)có˜>•X2==S- ss'UcX2URS5SS4$US:XaoURS5URS5pT/nU4SjnT RXu5 [U5H unupšUSU S-U-XIU -S-XJS-nM" USSnO(URS5SSnU(dS nSU-U-S-nX2U4$) aReturns line of text with user's change markup and line formatting. lines -- list of lines from the ndiff generator to produce a line of text from. When producing the line of text to return, the lines used are removed from this list. format_key -- '+' return first line in list with "add" markup around the entire line. '-' return first line in list with "delete" markup around the entire line. '?' return first line in list with add/delete/change intraline markup (indices obtained from second line) None return first line in list with no markup side -- indice into the num_lines list (0=from,1=to) num_lines -- from/to current line number. This is NOT intended to be a passed parameter. It is present as a keyword argument to maintain memory of the current line numbers between calls of this function. Note, this function is purposefully not defined at the module scope so that data it needs from its parent function (within whose context it is defined) does not need to be of module scope. r4NrrÿÚ?cóŠ•URURS5SUR5/5 URS5$)Nr4r)r8r„Úspan)Ú match_objectÚsub_infos rÚrecord_sub_infoÚ3_mdiff.._make_line..record_sub_info‡s=€Ø—‘ ×!3Ñ!3°AÓ!6°qÑ!9¸,×:KÑ:KÓ:MÐ NÔOØ#×)Ñ)¨!Ó,Ð,rÚÚr­)r_ÚsubÚreversed) r.Ú format_keyÚsideÚ num_linesÚtextÚmarkersr6r7ÚkeyÚbeginÚendÚ change_res €rÚ _make_lineÚ_mdiff.._make_linefsø€ð. ‹˜1Ñ‹ð Ñ Ø‘O E§I¡I¨a£L°°Ð$4Ð5Ð 5à ˜Ó Ø!ŸI™I a›L¨%¯)©)°A«,�'àˆHØ6>ô -ð �M‰M˜/Ô 2ô$,¨HÖ#5‘�‘K�UؘA˜e�} TÑ)¨#Ñ-¨d¸¨oÑ=¸dÑBÀ4ÈÀ:ÑM’ñ$6à˜˜�8‰Dð—9‘9˜Q“<  Ð#ˆDöØ�à˜*Ñ$ tÑ+¨dÑ2ˆDð‘ Ð%Ð%rc3ó@># •/nSup[U5S:a,UR[TS55 [U5S:aM,SRUVs/sHo3SPM sn5nUR S5(aUnGOÆUR S5(aT"USS5T"USS 5S4v• M©UR S 5(aUS -nT"US S5S S4v• MÕUR S 5(aT"US S5S peUS - SpGOBUR S5(aT"US S5T"USS 5S4v• GM.UR S5(aT"USS5T"US S 5S4v• GM^UR S 5(aUS -nT"US S5S S4v• GM‹UR S5(aUS - nS T"USS 5S4v• GM¸UR S5(aS T"USS 5peUS -SpO`UR S5(aUS - nS T"USS 5S4v• GM UR S5(aT"US S S S5T"US S 5S4v• GM@US:aUS - nSv• US:aMUS:”aUS -nSv• US:”aMUR S5(ag WWS4v• GMŽs snf7f)aQYields from/to lines of text with a change indication. This function is an iterator. It itself pulls lines from a differencing iterator, processes them and yields them. When it can it yields both a "from" and a "to" line, otherwise it will yield one or the other. In addition to yielding the lines of from/to text, a boolean flag is yielded to indicate if the text line(s) have differences in them. Note, this function is purposefully not defined at the module scope so that data it needs from its parent function (within whose context it is defined) does not need to be of module scope. )rrTrÚXrrrz-?+?r2r4z--++r½N)z--?+z--+ræz-+?z-?+z+--r¾)rèz+-r­F)N©rrrçT)rJNT)r>r8Únextr²Ú startswith) r.Únum_blanks_pendingÚnum_blanks_to_yieldrîr©Ú from_lineÚto_linerFÚdiff_lines_iterators €€rÚ_line_iteratorÚ_mdiff.._line_iteratoržsæøé€ðˆØ26Ñ/ÐØô�e“*˜q“.Ø— ‘ œTÐ"5°sÓ;Ô<ô�e“*˜q•.à—‘©UÓ3ªU T˜aœ©UÑ3Ó4ˆAØ�|‰|˜C× Ñ ð'9Ò#Ø—‘˜f×%Ñ%á   s¨1Ó-©z¸%ÀÀAÓ/FÈÐLÒLÙØ—‘˜f×%Ñ%ð# aÑ'Ð"Ù   s¨1Ó-¨t°TÐ9Ò9ÙØ—‘Ð3×4Ñ4ñ%/¨u°S¸Ó$;¸T˜'Ø9KÈAÑ9MÈaÒ$6Ø—‘˜e×$Ñ$á   t¨AÓ.± ¸5ÀÀQÓ0GÈÐMÒMÚØ—‘˜e×$Ñ$á   s¨1Ó-©z¸%ÀÀQÓ/GÈÐMÒMÚØ—‘˜c×"Ñ"à" aÑ'Ð"Ù   s¨1Ó-¨t°TÐ9Ò9ÚØ—‘˜e×$Ñ$ð# aÑ'Ð"Ø™J u¨S°Ó3°TÐ9Ò9ÚØ—‘˜l×+Ñ+à%)©:°e¸CÀÓ+B˜7Ø9KÈAÑ9MÈaÑ$6Ø—‘˜c×"Ñ"à" aÑ'Ð"Ø™J u¨S°Ó3°TÐ9Ò9ÚØ—‘˜c×"Ñ"á  ¡q ¨$¨qÓ1±*¸UÀ4ÈÓ2JÈ5ÐPÒPÚð&¨Ó)Ø# qÑ(Ð#Ø)Ò)ð&¨Õ)ð&¨Ó)Ø# qÑ(Ð#Ø)Ò)ð&¨Õ)ð�|‰|˜C× Ñ Øà ¨Ð,Ò,òMùò 4ùs%ƒAJÁJÁJÁ#G# •T"5n//p![U5S:Xd[U5S:Xa[[U5up4nUbURX545 UbURXE45 [U5S:XaMJ[U5S:XaM[UR S5up6UR S5upGX4U=(d U4v• M°![a gf=f7f)a,Yields from/to lines of text with a change indication. This function is an iterator. It itself pulls lines from the line iterator. Its difference from that iterator is that this function always yields a pair of from/to text lines (with the change indication). If necessary it will collect single from/to lines until it has a matching pair from/to pair to yield. Note, this function is purposefully not defined at the module scope so that data it needs from its parent function (within whose context it is defined) does not need to be of module scope. rN)r>rKÚ StopIterationr8r_) Ú line_iteratorÚ fromlinesÚtolinesrOrPÚ found_diffÚfromDiffÚto_diffrRs €rÚ_line_pair_iteratorÚ#_mdiff.._line_pair_iteratorösÕøé€ñ'Ó(ˆ ؘR�'Øä�y“> 1Ó$¬¨G« °a«ðÜ59¸-Ó5HÑ2�I¨ ðÑ(Ø×$Ñ$ iÐ%;Ô<ØÑ&Ø—N‘N GÐ#7Ô8ô�y“> 1Õ$¬¨G« °a­ð#,§-¡-°Ó"2Ñ ˆIØ&Ÿ{™{¨1›~Ñ ˆGØ X×%8°Ð9Ò 9ñøô %óÙðüs3ƒ*C®B?¼9CÁ7CÂ7CÂ? C à Cà C à Cr4F)NNN)ÚreÚcompilerrKrU)rWrXÚcontextr¹rºr^r\Úline_pair_iteratorÚlines_to_writeÚindexÚ contextLinesrYrOrPr@rRrFrErQs @@@@rÚ_mdiffre<s�ûé€óDð— ’ Ð+Ó,€Iô   °(ÓDÐà78¸°e÷6&öpV-õp:ñB-Ó.ÐØ�Ø%×%Ñ%ð �1‰ ˆØˆØð#$ d V¨WÑ%5�<؈JØ Ò%ðÜ59Ð:LÓ5MÑ2�I¨ ð‘O�Ø#,°zÐ"B� ‘ؘ‘ �ð Ô%ð‹Ø&Ò&Ø!(‘à!&�Ø�Þ Ø‘O�ؘ‘ �Ø"‘oÒ%Ø !Ñ#�÷ !�.ð % Q™YˆNð Þ$Ü59Ð:LÓ5MÑ2�I¨ æ!Ø)0°©™à&¨!Ñ+˜Ø#¨jÐ8Ò8÷%�nñ=ñ &øô%óÙðûô:!ó áð üsf†A D%ÁDÁD%Á-DÁ;D%Â2D%ÃD%à 4DÄD%Ä DÄD%ÄDÄD%Ä D"ÄD%Ä!D"Ä"D%an %(table)s%(legend)s a„ table.diff {font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace; border:medium} .diff_header {background-color:#e0e0e0} td.diff_header {text-align:right} .diff_next {background-color:#c0c0c0} .diff_add {background-color:#aaffaa} .diff_chg {background-color:#ffff77} .diff_sub {background-color:#ffaaaa}aZ %(header_row)s %(data_rows)s
aõ
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op
cóŒ•\rSrSrSr\r\r\r\rSr SSS\ 4Sjr SSS.S jjr S r S rS rS rSrSrSrSSjrSrg)r i‚aWFor producing HTML side by side comparison with change highlights. This class can be used to create an HTML table (or a complete HTML file containing the table) showing a side by side, line by line comparison of text with inter-line and intra-line change highlights. The table can be generated in either full or contextual difference mode. The following methods are provided for HTML generation: make_table -- generates HTML for a single side by side table make_file -- generates complete HTML file with a single side by side table See tools/scripts/diff.py for an example usage of this class. réNcó4•XlX lX0lX@lg)a˜HtmlDiff instance initializer Arguments: tabsize -- tab stop spacing, defaults to 8. wrapcolumn -- column number where lines are broken and wrapped, defaults to None where lines are not wrapped. linejunk,charjunk -- keyword arguments passed into ndiff() (used by HtmlDiff() to generate the side by side HTML differences). See ndiff() documentation for argument default values and descriptions. N)Ú_tabsizeÚ _wrapcolumnÚ _linejunkÚ _charjunk)r"ÚtabsizeÚ wrapcolumnr¹rºs rr#ÚHtmlDiff.__init__˜s€ð Œ Ø%ÔØ!ŒØ!�rzutf-8)Úcharsetcó¸•UR[URURUR XX4XVS9US9-R US5R U5$)a­Returns HTML file of side by side comparison with change highlights Arguments: fromlines -- list of "from" lines tolines -- list of "to" lines fromdesc -- "from" file column header string todesc -- "to" file column header string context -- set to True for contextual differences (defaults to False which shows full differences). numlines -- number of context lines. When context is set True, controls number of lines displayed before and after the change. When context is False, controls the number of lines to place the "next" link anchors before the next change (so click of "next" link jumps to just before the change). charset -- charset of the HTML document )r`Únumlines)ÚstylesÚlegendÚtablerpÚxmlcharrefreplace)Ú_file_templaterÚ_stylesÚ_legendÚ make_tabler,r')r"rWrXÚfromdescÚtodescr`rrrps rÚ make_fileÚHtmlDiff.make_file©s`€ð&×#Ñ#¤dØ—<‘<Ø—<‘<Ø—/‘/ )°hØ*1ð"ðFàñ ' ñ ÷ ‰6�'Ð.Ó /·±°w³ð  @rcó†^•U4SjnUVs/sH oC"U5PM nnUVs/sH oC"U5PM nnX4$s snfs snf)aÈReturns from/to line lists with tabs expanded and newlines removed. Instead of tab characters being replaced by the number of spaces needed to fill in to the next tab stop, this function will fill the space with tab characters. This is done so that the difference algorithms can identify changes in a file when tabs are replaced by spaces and vice versa. At the end of the HTML generation, the tab characters will be replaced with a nonbreakable space. cóÄ>•URSS5nURTR5nURSS5nURSS5RS5$)Nr­r9Ú rç)rsÚ expandtabsriré)rîr"s €rÚ expand_tabsÚ2HtmlDiff._tab_newline_replace..expand_tabsÎsSø€à—<‘<  DÓ)ˆDà—?‘? 4§=¡=Ó1ˆDð—<‘<  DÓ)ˆDØ—<‘<  SÓ)×0Ñ0°Ó6Ð 6rr)r"rWrXrƒrîs` rÚ_tab_newline_replaceÚHtmlDiff._tab_newline_replaceÄsMø€õ 7ñ4=Ó=²9¨4�[ Ö&±9ˆ Ð=Ù18Ó9²¨�;˜tÖ$±ˆÐ9ØÐ Ð ùò>ùÚ9sŒ9£>cóè•U(dURX#45 g[U5nURnXE::dXCRS5S-- U::aURX#45 gSnSnSnXu:aBXd:a=X6S:XaUS- nX6nUS- nOX6S:XaUS- nSnO US- nUS- nXu:aXd:aM=USUn X6Sn U(a U S-n SU-U -n URX)45 UR USU 5 g) atBuilds list of text lines by splitting text lines at wrap point This function will determine if the input text line needs to be wrapped (split) into separate lines. If so, the first wrap point will be determined and the first line appended to the output text line list. This function is used recursively to handle the second part of the split line to further split it. Nr9r™rrrr4r:Ú>)r8r>rjÚcountÚ _split_line) r"Ú data_listÚline_numr@rzr€r@rEÚmarkÚline1Úline2s rrŠÚHtmlDiff._split_lineÛs)€öØ × Ñ ˜h˜_Ô -Ø ô�4‹yˆØ×ÑˆØ ‹K˜d§Z¡Z°Ó%5°aÑ%7Ñ8¸SÓ@Ø × Ñ ˜h˜_Ô -Ø ð ˆØ ˆØˆØ‹g˜!›(؉w˜$‹Ø�Q‘�Ø‘w�Ø�Q‘‘Ø‘˜D“Ø�Q‘�Ø‘à�Q‘�Ø�Q‘�ð‹g˜!�(ð�R�a�ˆØ�R�ˆö ؘD‘LˆEؘ4‘K %Ñ'ˆEð ×ј(Ð)Ô*ð ×ј 3 uÕ-rc#óT# •UHžup#nUcX#U4v• MX#supVupx//p©URX•U5 URX§U5 U (d U (dMPU (aU RS5nOSnU (aU RS5nOSnX#U4v• U (aMEU (aMNM  g7f)z5Returns iterator that splits (wraps) mdiff text linesNr)rrr­)rŠr_) r"ÚdiffsÚfromdataÚtodataÚflagÚfromlineÚfromtextÚtolineÚtotextÚfromlistÚtolists rÚ _line_wrapperÚHtmlDiff._line_wrappersªé€ó%*Ñ ˆH˜Dà‰|Ø dÐ*Ò*ÙØ2:Ð /Ñ ˆX¡ ð! �VØ × Ñ ˜X¨xÔ 8Ø × Ñ ˜V¨6Ô 2öŸf˜fÞØ'Ÿ|™|¨A›‘Hà'�HÞØ#ŸZ™Z¨›]‘Fà%�FØ dÐ*Ò*÷�(Ÿfšfò%*ùs‚AB(ÁAB(ÂB(Â#B(có@•///pCnUH^upVnURUR"SU/UQ765 URUR"SU/UQ765 URU5 M` X#U4$![a% URS5 URS5 NGf=f)z›Collects mdiff output into separate lists Before storing the mdiff from/to data into a list, it is converted into a single line of text with HTML markup. rr4N)r8Ú _format_liner)r"r’ršr›Úflaglistr“r”r•s rÚ_collect_linesÚHtmlDiff._collect_lines.s£€ð$& b¨˜ˆã$)Ñ ˆH˜Dð $à—‘ × 1Ò 1°!°DÐ C¸(Ò CÔDØ— ‘ ˜d×/Ò/°°$Ð?¸Ò?Ô@ð �O‰O˜DÖ !ñ%*ð˜xÐ'Ð'øô ó $à—‘ Ô%Ø— ‘ ˜dÖ#ð $ús�AA.Á.,BÂBcó"•SU-nSURU<U<S3nURSS5RSS5RS S 5nURS S 5R5nS U<SU<SU<S3$![a SnNof=f)zÞReturns HTML markup of "from" / "to" text lines side -- 0 or 1 indicating "from" or "to" text flag -- indicates if difference on line linenum -- line number (used for line number column) text -- line text to be marked up z%dz id="Ú"rrÚ&z&rˆz>Úz)Ú_prefixrrsré)r"r>r•Úlinenumr@Úids rrŸÚHtmlDiff._format_lineCs“€ð ؘW‘n‰GØ!%§¡¨dÓ!3³GÐ<ˆBð �\‰\˜#˜gÓ &× .Ñ .¨s°6Ó :× BÑ BÀ3ÀvÓ Nˆð�|‰|˜C Ó)×0Ñ0Ó2‰ó“W›Tð#ð #øôó àŠBð ús‚A?Á? B Bcó’•S[R-nS[R-n[=RS- slX/Ulg)zCreate unique anchor prefixeszfrom%d_zto%d_r4N)r Ú_default_prefixr¨)r"Ú fromprefixÚtoprefixs rÚ _make_prefixÚHtmlDiff._make_prefixZs?€ð ¤×!9Ñ!9Ñ9ˆ ØœX×5Ñ5Ñ5ˆÜ× Ò  AÑ%Õ à"Ð,ˆ� rcóŠ•URSnS/[U5-nS/[U5-nSupšSn [U5HAupÍU (a3U (d*Sn U n [SXÅ- /5n SXi4-X|'U S- n SXi4-X‹'M=M?Sn MC U(dS/nS/nS/nSn U(aS /nUnOS /=pUS(dS U-US'S U-X‹'XX8U4$) zMakes list of "next" linksr4rr)rFrTz id="difflib_chg_%s_%d"z"nFz2 No Differences Found z( Empty File z!fz#t)r¨r>r6r€)r"ršr›r r`rrr¯Únext_idÚ next_hrefÚnum_chgÚ in_changer r@r•s rÚ_convert_flagsÚHtmlDiff._convert_flagses€ð—<‘< ‘?ˆð�$”s˜8“}Ñ$ˆØ�Dœ˜X›Ñ&ˆ Ø%ш؈ܠÖ)‰FˆAÞÞ Ø $�IØ�Dô˜Q˜q™z˜NÓ+�AØ!:¸hÐ=OÑ!O�G‘Jð˜q‘L�GØ&JØ!ðN+ñ'+�I“Oñ!ð"’ ñ!*ö$Ø�wˆHØ�dˆGؘˆI؈DÞØPÐQ�Ø!‘à%OÐ$PÐP�à˜�{Ø>ÀÑIˆI�a‰Là?À8ÑLˆ ‰à˜x°'Ð9Ð9rc ó`•UR5 URX5upU(aUnOSn[XXpRURS9nUR (aUR U5nURU5upšn URXšXµU5upšp¼n /nSn[[U 55HKnU UcUS:”aURS5 M"M$URXýUU UU UU UU U4-5 MM U(dU(aSS<SU-<S<SU-<S 3nOS nUR[S RU5UURS S 9-nUR!S S5R!SS5R!SS5R!SS5R!SS5$)a†Returns HTML table of side by side comparison with change highlights Arguments: fromlines -- list of "from" lines tolines -- list of "to" lines fromdesc -- "from" file column header string todesc -- "to" file column header string context -- set to True for contextual differences (defaults to False which shows full differences). numlines -- number of context lines. When context is set True, controls number of lines displayed before and after the change. When context is False, controls the number of lines to place the "next" link anchors before the next change (so click of "next" link jumps to just before the change). Nr¸zV %s%s%s%s rz) z z!
z+%sz rrr4)Ú data_rowsÚ header_rowrz+zz-zz^zr:zr�r§)r°r…rerkrlrjrœr¡r·rLr>r8Ú_table_templaterr²r¨rs)r"rWrXr{r|r`rrÚ context_linesr’ršr›r r´r³r©Úfmtr@r»rus rrzÚHtmlDiff.make_table”sÄ€ð( ×ÑÔð !×5Ñ5°iÓHш ö Ø$‰Mà ˆMÜ�y¨ÇÁØ#Ÿ~™~ñ/ˆð × × Ø×&Ñ& uÓ-ˆEð$(×#6Ñ#6°uÓ#=Ñ ˆ˜ð6:×5HÑ5HØ ˜H¨Xó67Ñ2ˆ˜¨7ð ˆð7ˆä”s˜8“}Ö%ˆAؘ‰{Ñ"ð�q“5Ø—H‘HÐJÖKñ𗑘#¨¡¨I°a©L¸À!¹Ø+4°Q©<¸¸q¹ ð!CñCöDñ&ö –vøâ3Ø=ÀÓHÚ3Ø=ÀÔFð H‰Jð ˆJà×$Ñ$¤tØ—g‘g˜a“jØ!Ø—<‘< ‘?ñ($ñ$ˆð �}‰}˜UÐ#<Ó=ß‘W˜UÐ#<Ó=ß‘W˜UÐ#<Ó=ß‘W˜T )Ó,ß‘W˜T (Ó+ð  ,r)rlrkr¨rirj)rrrrFé)ršr›rœr�ržrwrxr¼ryr­rr#r}r…rŠrœr¡rŸr°r·rzr¡rrrr r ‚s†ñ ð$€NØ€GØ%€OØ€GØ€Oà¨4¸Ø+ô"ð"ACØ*+ð@Ø8?ö@ò6!ò.5.òn+ò8(ò*#ò. -ò-:ð^INØ÷M,rr c#ó¨# •SSS.[U5nSU4nUHnUSSU;dMUSSv• M g![a [SU-5Sef=f7f)aì Generate one of the two sequences that generated a delta. Given a `delta` produced by `Differ.compare()` or `ndiff()`, extract lines originating from file 1 or 2 (parameter `which`), stripping off line prefixes. Examples: >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True), ... 'ore\ntree\nemu\n'.splitlines(keepends=True)) >>> diff = list(diff) >>> print(''.join(restore(diff, 1)), end="") one two three >>> print(''.join(restore(diff, 2)), end="") ore tree emu rærè)r4rÿz)unknown delta choice (must be 1 or 2): %rNrÒrÿ)ÚintÚKeyErrorr£)ÚdeltaÚwhichr{Úprefixesrîs rrråsvé€ð,.ؘ4Ñ ¤ U£Ñ,ˆð�cˆ{€HÛˆØ ��ˆ8�xÕ Ø�q�r�(ŒNòøô ó.ÜÐDØ"ñ#ó$Ø)-ð .ð.üs‚A„5•A© AµAÁAcó4•SSKnSSKnURU5$)Nr)ÚdoctestÚdifflibÚtestmod)rÈrÉs rÚ_testrËs€ßØ �?‰?˜7Ó #Ð#rÚ__main__)r™g333333ã?)z )rrrrrrrrr™rç)rrrrr™ó )&ržÚ__all__Úheapqrr¤Ú collectionsrÚ _namedtupleÚtypesrr rrrrµrr^r_Úmatchrrrûr rr rr rrerwrxr¼ryÚobjectr rrËršrrrÚrÕsðñò8 >€õ(Ý1Ýá�G˜ZÓ(€ò÷ k 2ñk 2ô\.&òb÷l!ñl!ó~  àŸ:š:Ð&6Ó7×=Ñ=ô!ô ò. -ð=?Ø.2ôB%òR =ð,.Ø?CôJ1òXKð"25Ø?Dô6ð<Ð(9ô#4ðJ(,°dØ%ôKð\ €ð( 0€ð€ð €ô"_,ˆvô_,ðB òò@$ð ˆzÓÙ …Gðr