754B652DAAD22F55CD68EAC ˆ¾Ã ƒh¹ÂÀÅ53CEF94F6CC14EC9A7E50B5 !ˆ¿Ã „mæÞÂÀÅ?÷!a ´ikEã@s0dZgd¢ZddlmZddlmZddlm Z eddƒZ dd „Z Gd d „d ƒZ d:dd„Z dd„ZGdd„dƒZddlZe d¡jfdd„Zd;dd„Zdd„Zdd)d*„Zdefd+d,„Zddefd-d.„Zd/Zd0Zd1Zd2Z Gd3d4„d4e!ƒZ"[d5d6„Z#d7d8„Z$e%d9k�r,e$ƒdS)?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 sizecCs|rd||SdS)Ng@çð?©)ÚmatchesÚlengthrrú/usr/lib64/python3.9/difflib.pyÚ_calculate_ratio's rc@s~eZdZdZddd„Zdd„Zd d „Zd d „Zd d„Zd dd„Z dd„Z dd„Z d!dd„Z dd„Z dd„Zdd„ZeeƒZdS)"rao 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(), 3)) 0.866 >>> 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 f