/opt/imh/python3.13/lib/python3.13/__pycache__
NameSizeModeActions
abc.cpython-313.pyc79280644editdlrm
antigravity.cpython-313.pyc10000644editdlrm
argparse.cpython-313.pyc1040800644editdlrm
ast.cpython-313.pyc1030860644editdlrm
base64.cpython-313.pyc258320644editdlrm
bdb.cpython-313.pyc405800644editdlrm
bisect.cpython-313.pyc35120644editdlrm
bz2.cpython-313.pyc151800644editdlrm
calendar.cpython-313.pyc397080644editdlrm
cmd.cpython-313.pyc189770644editdlrm
code.cpython-313.pyc157990644editdlrm
codecs.cpython-313.pyc405720644editdlrm
codeop.cpython-313.pyc66550644editdlrm
colorsys.cpython-313.pyc45190644editdlrm
compileall.cpython-313.pyc206150644editdlrm
configparser.cpython-313.pyc689660644editdlrm
contextlib.cpython-313.pyc305090644editdlrm
contextvars.cpython-313.pyc2760644editdlrm
copy.cpython-313.pyc106450644editdlrm
copyreg.cpython-313.pyc75510644editdlrm
cProfile.cpython-313.pyc86790644editdlrm
csv.cpython-313.pyc207150644editdlrm
dataclasses.cpython-313.pyc478390644editdlrm
datetime.cpython-313.pyc4260644editdlrm
decimal.cpython-313.pyc30170644editdlrm
difflib.cpython-313.pyc720550644editdlrm
dis.cpython-313.pyc475320644editdlrm
doctest.cpython-313.pyc1076920644editdlrm
enum.cpython-313.pyc858660644editdlrm
filecmp.cpython-313.pyc150420644editdlrm
fileinput.cpython-313.pyc206480644editdlrm
fnmatch.cpython-313.pyc68190644editdlrm
fractions.cpython-313.pyc383840644editdlrm
ftplib.cpython-313.pyc423460644editdlrm
functools.cpython-313.pyc422860644editdlrm
genericpath.cpython-313.pyc78260644editdlrm
getopt.cpython-313.pyc84790644editdlrm
getpass.cpython-313.pyc73260644editdlrm
gettext.cpython-313.pyc225760644editdlrm
glob.cpython-313.pyc236810644editdlrm
graphlib.cpython-313.pyc102120644editdlrm
gzip.cpython-313.pyc319930644editdlrm
hashlib.cpython-313.pyc82910644editdlrm
heapq.cpython-313.pyc177850644editdlrm
hmac.cpython-313.pyc106750644editdlrm
imaplib.cpython-313.pyc626620644editdlrm
inspect.cpython-313.pyc1365370644editdlrm
io.cpython-313.pyc42900644editdlrm
ipaddress.cpython-313.pyc919790644editdlrm
keyword.cpython-313.pyc10560644editdlrm
linecache.cpython-313.pyc85670644editdlrm
locale.cpython-313.pyc590140644editdlrm
lzma.cpython-313.pyc157330644editdlrm
mailbox.cpython-313.pyc1187480644editdlrm
mimetypes.cpython-313.pyc249130644editdlrm
modulefinder.cpython-313.pyc284070644editdlrm
netrc.cpython-313.pyc93410644editdlrm
ntpath.cpython-313.pyc284840644editdlrm
nturl2path.cpython-313.pyc27520644editdlrm
numbers.cpython-313.pyc140470644editdlrm
opcode.cpython-313.pyc40770644editdlrm
operator.cpython-313.pyc173800644editdlrm
optparse.cpython-313.pyc675940644editdlrm
os.cpython-313.pyc458640644editdlrm
pdb.cpython-313.pyc1061180644editdlrm
pickle.cpython-313.pyc784190644editdlrm
pickletools.cpython-313.pyc804420644editdlrm
pkgutil.cpython-313.pyc199740644editdlrm
platform.cpython-313.pyc446900644editdlrm
plistlib.cpython-313.pyc431130644editdlrm
poplib.cpython-313.pyc184400644editdlrm
posixpath.cpython-313.pyc181150644editdlrm
pprint.cpython-313.pyc297130644editdlrm
profile.cpython-313.pyc225780644editdlrm
pstats.cpython-313.pyc378720644editdlrm
pty.cpython-313.pyc74200644editdlrm
pyclbr.cpython-313.pyc151590644editdlrm
pydoc.cpython-313.pyc1397200644editdlrm
py_compile.cpython-313.pyc100840644editdlrm
queue.cpython-313.pyc173480644editdlrm
quopri.cpython-313.pyc95750644editdlrm
random.cpython-313.pyc352710644editdlrm
reprlib.cpython-313.pyc111750644editdlrm
rlcompleter.cpython-313.pyc85870644editdlrm
runpy.cpython-313.pyc144060644editdlrm
sched.cpython-313.pyc76120644editdlrm
secrets.cpython-313.pyc25190644editdlrm
selectors.cpython-313.pyc263700644editdlrm
shelve.cpython-313.pyc133060644editdlrm
shlex.cpython-313.pyc148670644editdlrm
shutil.cpython-313.pyc674670644editdlrm
signal.cpython-313.pyc45590644editdlrm
site.cpython-313.pyc316620644editdlrm
smtplib.cpython-313.pyc473750644editdlrm
socket.cpython-313.pyc422340644editdlrm
socketserver.cpython-313.pyc346670644editdlrm
sre_compile.cpython-313.pyc6420644editdlrm
sre_constants.cpython-313.pyc6450644editdlrm
sre_parse.cpython-313.pyc6380644editdlrm
ssl.cpython-313.pyc652190644editdlrm
stat.cpython-313.pyc55380644editdlrm
statistics.cpython-313.pyc711130644editdlrm
string.cpython-313.pyc116660644editdlrm
stringprep.cpython-313.pyc252750644editdlrm
struct.cpython-313.pyc3400644editdlrm
subprocess.cpython-313.pyc819690644editdlrm
symtable.cpython-313.pyc232110644editdlrm
tabnanny.cpython-313.pyc124320644editdlrm
tarfile.cpython-313.pyc1258450644editdlrm
tempfile.cpython-313.pyc410080644editdlrm
textwrap.cpython-313.pyc179490644editdlrm
this.cpython-313.pyc14270644editdlrm
threading.cpython-313.pyc633120644editdlrm
timeit.cpython-313.pyc146530644editdlrm
token.cpython-313.pyc35880644editdlrm
tokenize.cpython-313.pyc254490644editdlrm
trace.cpython-313.pyc339780644editdlrm
traceback.cpython-313.pyc721390644editdlrm
tracemalloc.cpython-313.pyc274280644editdlrm
tty.cpython-313.pyc26790644editdlrm
turtle.cpython-313.pyc1751510644editdlrm
types.cpython-313.pyc155600644editdlrm
typing.cpython-313.pyc1545970644editdlrm
uuid.cpython-313.pyc323970644editdlrm
warnings.cpython-313.pyc295530644editdlrm
wave.cpython-313.pyc332520644editdlrm
weakref.cpython-313.pyc318180644editdlrm
webbrowser.cpython-313.pyc269010644editdlrm
zipapp.cpython-313.pyc104090644editdlrm
zipimport.cpython-313.pyc265220644editdlrm
_aix_support.cpython-313.pyc47320644editdlrm
_android_support.cpython-313.pyc76370644editdlrm
_apple_support.cpython-313.pyc34970644editdlrm
_collections_abc.cpython-313.pyc467080644editdlrm
_colorize.cpython-313.pyc40260644editdlrm
_compat_pickle.cpython-313.pyc72070644editdlrm
_compression.cpython-313.pyc78200644editdlrm
_ios_support.cpython-313.pyc27310644editdlrm
_markupbase.cpython-313.pyc124480644editdlrm
_opcode_metadata.cpython-313.pyc106930644editdlrm
_osx_support.cpython-313.pyc181420644editdlrm
_pydatetime.cpython-313.pyc945900644editdlrm
_pydecimal.cpython-313.pyc2170580644editdlrm
_pyio.cpython-313.pyc1117930644editdlrm
_pylong.cpython-313.pyc111730644editdlrm
_py_abc.cpython-313.pyc72070644editdlrm
_sitebuiltins.cpython-313.pyc49170644editdlrm
_strptime.cpython-313.pyc345000644editdlrm
_sysconfigdata__linux_x86_64-linux-gnu.cpython-313.pyc585830644editdlrm
_threading_local.cpython-313.pyc55380644editdlrm
_weakrefset.cpython-313.pyc120640644editdlrm
__future__.cpython-313.pyc47370644editdlrm
__hello__.cpython-313.pyc9810644editdlrm
Edit: /opt/imh/python3.13/lib/python3.13/__pycache__/difflib.cpython-313.pyc (72055B)
eESr/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_matchesndiffrestoreSequenceMatcherDifferIS_CHARACTER_JUNK IS_LINE_JUNK context_diff unified_diff diff_bytesHtmlDiffMatch)nlargest) namedtuple) GenericAliasr za b sizec"U(aSU-U- $g)Ng@?)matcheslengths -/opt/imh/python3.13/lib/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. NcZXlS=UlUlX@lUR X#5 g)aConstruct 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)isjunkabautojunkset_seqs)selfrrrr s r__init__SequenceMatcher.__init__xs)v   arcHURU5 URU5 g)zsSet the two sequences to be compared. >>> s = SequenceMatcher() >>> s.set_seqs("abcd", "bcde") >>> s.ratio() 0.75 N)set_seq1set_seq2)r"rrs rr!SequenceMatcher.set_seqss a arcJXRLagXlS=UlUlg)aSet 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)rmatching_blocksopcodes)r"rs rr&SequenceMatcher.set_seq1s$* ; .22t|rcxXRLagXlS=UlUlSUlUR 5 g)aSet 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_seq2s5* ; .22t| rcnURn0=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)Nd)rb2j enumerate setdefaultappendsetbjunkrkeysaddbpopularlenr items) r"rr5ieltindicesjunkrpopularnntestidxss r __chain_bSequenceMatcher.__chain_b s  FF3lFAnnS"-G NN1 #  E! T xxz#;;HHSM"H#&%'  F ==Q#XHqLE YY[ t9u$KK$)H &=rcURURURURR4upVpxUc [ U5nUc [ U5nXSpn 0n /n [ X5HknU Rn0nURX^U 5H@nUU:aM UU:a O1U"US- S5S-=nUU'UU :dM/UU- S-UU- S-Upn MB Un Mm X:acX:a^U"XjS- 5(dLXYS- XjS- :Xa<U S- U S- U S-pn 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-pn 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[XU 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>rangegetr )r"aloahiblobhirrr5isbjunkbestibestjbestsizej2lennothingr@j2lengetnewj2lenjks rfind_longest_match"SequenceMatcher.find_longest_match1st"VVTVVTXXtzz7N7NNc ;a&C ;a&C!$1hsAyyHHWWQT7+s78"*1Q3"2Q"66HQKx<-.qSUAaCE1(E(,E!(kek!!G*%%ajAAgJ&%*1WeAgxz(Ekek!!G*%%ajAAgJ&ns"u~';!(N+,,h18^#44 MHns"u~';!(N+,,h18^#44kekaaj!!ajAAgJ&%*1WeAgxz(Ekekaaj!!ajAAgJ&ns"u~';ah'((h18^#44!|Hns"u~';ah'((h18^#44U8,,rc<URb UR$[UR5[UR5p!SUSU4/n/nU(aUR 5upVpxUR XVXx5=uppU (aWUR U 5 XY:aXz:aUR XYXz45 X-U:a!X-U:aUR X-XjU -U45 U(aMUR5 S=n =p/nUH=unnnX-U:XaX-U:XaUU- nMU(aUR XU45 UUUpn M? U(aUR XU45 UR XS45 [[[RU55UlUR$)aReturn 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>rrpopr\r8sortlistmapr _make)r"lalbqueuer*rNrOrPrQr@rZr[xi1j1k1 non_adjacenti2j2k2s rget_matching_blocks#SequenceMatcher.get_matching_blockss&    +'' 'TVVc$&&kBRB !& Cc11#CE EGA!&&q)7swLL##!1239sLL!#saC!56e  R )JBBw"}Bb  '' 5R*     -ba[*#C \$BC###rc>URb UR$S=p/=UlnUR5HcupEnSnX:aX%:aSnOX:aSnOX%:aSnU(aURXqXBU45 XF-XV-p!U(dMOURSXAXR45 Me U$)aReturn 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) rreplacedeleteinsertequal)r+ror8)r"r@rZansweraibjsizetags r get_opcodesSequenceMatcher.get_opcodess: << #<<   "" v 446LBD Cv!& r247BGqt 68'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)]] )rvrr4rr4rrvr4N)r|maxminr8r>) r"rEcodesr{rhrlrirmnngroups rget_grouped_opcodes#SequenceMatcher.get_grouped_opcodes#sX2  "*+E 8A;' !"'( CRRCqDM2s2!t}b@E!H 9Q<7 ""') CRRRACqDMAE"I U#( CRRg~"%"* cs2!t}b#bQ$-HI RAB1 B LL#22. /$) #e*a-E!HQK7,BK-C5sD4D6c[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).0triples r (SequenceMatcher.ratio..ksJ/IVRj/Is)sumrorr>rr)r"rs rratioSequenceMatcher.ratioUs?,Jt/G/G/IJJTVVs466{)BCCrcURc30=UlnURHnURUS5S-X'M URn0nURSpTURH;nU"U5(aX2nOURUS5nUS- X2'US:dM6US-nM= [ U[ UR5[ UR5-5$)zReturn 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.rAavailavailhasrnumbs r quick_ratioSequenceMatcher.quick_rations ?? "+- -DOjvv",..a"81"< __ !..'66C}}z!~~c1-EJax!A+ TVVs466{)BCCrc[UR5[UR5p![[ X5X-5$)zReturn 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 rreal_quick_ratio SequenceMatcher.real_quick_ratios0TVVc$&&kB B RW55r) rr rr5r:r=r.rr*r+)NrrrrT)rNrN))__name__ __module__ __qualname____firstlineno____doc__r#r!r&r'r/r\ror|rrrr classmethodr__class_getitem____static_attributes__rrrrr,s]HT>@ 34X%Nr-hE$N5n0dD2D: 6$L1rrcUS: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&rrrr8 _nlargest)word possibilitiesrEcutoffresultsrgscores rrrs: 6344 & C vGHH FAJJt  1   6 ) ==?f $ 779  MM1779a. ) q !F$ %f(%Af %% %sC0cDSRS[X555$)zAReplace whitespace with the original whitespace characters in `s`rrc3d# UH&upUS:XaUR5(aUOUv M( g7f) N)isspace)rctag_cs rr$_keep_original_ws..s.%HAc\aiikku4%s.0)joinzip)rtag_ss r_keep_original_wsrs$ 77A  rcF\rSrSrSrS SjrSrSrSrSr S r S r S r g) ria 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. NcXlX 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. Nlinejunkcharjunk)r"rrs rr#Differ.__init__*s(!  rc #t# [URX5nUR5HupEpgnUS:XaURXXbXx5n O]US:XaUR SXU5n OCUS:XaUR SX'U5n O)US:XaUR SXU5n O[ SU<35eU S hvN 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)rrr|_fancy_replace_dumpr) r"rrcruncherr{rNrOrPrQgs rcompareDiffer.compareAs4#4==!7'/';';'= #Cci''AJJsAC0JJsAC0JJsAC0 S!:;;LL(> sB*B8,B6- B8c#J# [X45HnU<SX%<3v M g7f)z4Generate comparison results for a same-tagged range.rN)rL)r"r{rglohir@s rr Differ._dumpjs rA !$' 's!#c## X#:aXV:deXe- X2- :a'URSXEU5nURSXU5nO&URSXU5nURSXEU5nXx4H n U ShvN M gN 7f)Nrr)r) r"rrNrOrrPrQfirstsecondrs r_plain_replaceDiffer._plain_replaceosySY&& 9sy ZZQS1EZZQS1FZZQS1EZZQS1FALL sA/A=1A;2 A=c#"# Supx[UR5n Sup[XV5Hn XLn U RU 5 [X#5HynXnX:XaU cXpMU R U5 U R 5U:dM:U R 5U:dMPU R5U:dMfU R5XnnnM{ M Xx:a%U cURXX4XV5ShvN gXSnnnOSn URXWXEW5ShvN UUUUnnU cS=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 URUUUU5ShvN OSU-v URUUS-X4US-U5ShvN gGNNN5N 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 ? ^ ^ ^ )gGz?g?NNNrrrrs^rtrrurrvrr r4)rrrLr'r&rrrr _fancy_helperr!r|r_qformat)r"rrNrOrrPrQ best_ratiorreqieqjrZryr@rxbest_ibest_jaeltbeltatagsbtagsr{ai1ai2bj1bj2rdres rrDiffer._fancy_replace}sb*( "4==1 sAB   b !3_T8{#$S!!"%,,.;**,z9nn&3191A1J!%!(  {..qssHHH),3JFFJC %%afafEEEvY& d ; EE   dD )+3+?+?+A'S#sCsC#IB)#S2X%ES2X%EH_S2X%EH_S2X%EG^S2X%ES2X%E$%>??,B}}T4> > >+ %%a36!8SIIIQI F, ? Js[BHHH49H-H.$HH CHH *HH H H H Hc## /nX#:a-XV:aURXX4XV5nO,URSXU5nOXV:aURSXEU5nUShvN gN7f)Nrr)rr)r"rrNrOrrPrQrs rrDiffer._fancy_helpersX  9y''AJJsAC0 Y 3,A sAAAAc## [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)rrstrip)r"alineblinerrs rrDiffer._qformatsh "%/668!%/668Ul ugR. Ul ugR.  sA!A#)rrr) rrrrrr#rrrrrrrrrrrrs0Sj!.'R( \J| !rrNz \s*(?:#\s*)?$cU"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)linepats rrrs t9D  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)chwss rrr%s 8Orc|US-nX- nUS:XaSRU5$U(dUS-nSRX#5$z Convert range to the "ed" formatr4z{}z{},{}formatstartstop 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 5nSRXU5v 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 +++ {}{}{}rrr4rz@@ -{} +{} @@{}rvr>rtrsr>rursr) _check_typesrrrr)rrfromfiletofile fromfiledate tofiledaterElinetermstartedrfromdatetodaterlast file1_range file2_ranger{rhrlrirmrs rr r GsSRx8LG a*>>qAG6Bv}}\2H2 +E!Hd1g> &&{JJ#( CRRg~bHD*$%++bHD*$%++bHD*$%$)Bs DD<D<cUS-nX- nU(dUS-nUS::aSRU5$SRX"U-S- 5$rrrs r_format_range_contextrsO 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 rrz! r)rurtrsrvFNTrrrz *** {}{}{}rrrz***************r4rz *** {} ****{}c36# UHun o!S;v M g7f)>rtrsNrrr{_s rrcontext_diff..I5Q1a++5rurrz --- {} ----{}c36# UHun o!S;v M g7f)>rursNrrs rrrrrrt)rdictrrrrany)rrrrrrrErprefixrrrr rr r r{rhrlrrr rirms rr r sXx8L dD EFG a*>>qAG6Bv}}\2H2 $$[;; I5I I I%*!RQ(? !"R$SkD00!)&+ ,E!Hd1g> $$[(;; I5I I I%*!Q2r(? !"R$SkD00!)&+1BsC.decodesK *88G%67 7 *G$$a)CC.c ) *s A *AA r%r&N)rarbencode) dfuncrrrrrrrErr'linesrs rr r s* S^A S^AhH F^F,'L #JhH !,A PEkk'#455sA=A?c6[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)rrrrs rrrsF ( % - -a 33rc#N^^^^# SSKnUR"S5m[XX45mSS/4U4SjjmUU4SjmU4SjnU"5nUc UShvN gUS- nSnSS/U-pSn U SLa%[U5upn X-nXU 4X'U S- n U SLaM%X:aS v UnOU nSn U(aX-nU S- n Xv US-nU(aMUS- nU(a/[U5upn U (aUS- nOUS-nXU 4v U(aM/MN![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 unupUSU 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?cURURS5SUR5/5 URS5$)Nr4r)r8rspan) match_objectsub_infos rrecord_sub_info3_mdiff.._make_line..record_sub_infos=!3!3A!6q!9,:K:K:M NO#))!,,rr)r_subreversed) r. format_keyside num_linestextmarkersr6r7keybeginend change_res r _make_line_mdiff.._make_linefs. 1  OEIIaL$45 5  !IIaL%))A,'H6> - MM/ 2$,H#5KUAe}T)#-do=dB4:M$68D99Q<#D*$t+d2D%%rc3@># /nSup[U5S:a,UR[TS55 [U5S:aM,SRUVs/sHo3SPM sn5nUR S5(aUnGOUR S5(aT"USS5T"USS 5S4v MUR S 5(aUS -nT"US S5S S4v MUR 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 GMUR S5(aUS - nS T"USS 5S4v GMUR 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 GMs 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. )rrTrXrrrz-?+?r2r4z--++rN)z--?+z--+rz-+?z-?+z+--r)rz+-rF)NrrrT)rJNT)r>r8nextr startswith) r.num_blanks_pendingnum_blanks_to_yieldrr from_lineto_linerFdiff_lines_iterators r_line_iterator_mdiff.._line_iterators26/e*q. T"5s;<e*q.U3UTaU34A||C  '9#f%% s1-z%A/FLLf%%#a'" s1-tT99344%/uS$;T'9KA9Ma$6e$$ tA. 5Q0GMMe$$ s1-z%Q/GMMc"""a'" s1-tT99e$$#a'"JuS3T99l++%):eC+B79KA9Ma$6c"""a'"JuS3T99c"" q$q1*U42J5PP&)#q(#))&)&)#q(#))&)||C  ,,M 4s%AJJJ#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 fromlinestolinesrOrP found_difffromDiffto_diffrRs r_line_pair_iterator#_mdiff.._line_pair_iterators'( R'y>1$G a59-5H2I ($$i%;<&NNG#78y>1$G a#,--"2 I&{{1~ GX%89 9 %s3*CB?9C7C7C? C  C C  Cr4F)NNN)recompilerrKrU)rWrXcontextrrr^r\line_pair_iteratorlines_to_writeindex contextLinesrYrOrPr@rRrFrErQs @@@@r_mdiffre<sD +,I (D78e6&pV-p:B-.%%% 1 #$dVW%5<J%59:L5M2I O#,z"B  %&&!(!& O "o%!# !. %QYN $59:L5M2I !)0&!+#j88%n= &%:!  sfA D%DD%-D;D%2D%D% 4DD% DD%DD% 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 iaWFor 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. rNc4XlX lX0lX@lg)aHtmlDiff 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 wrapcolumnrrs rr#HtmlDiff.__init__s %!!rzutf-8)charsetcUR[URURUR XX4XVS9US9-R US5R U5$)aReturns 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)styleslegendtablerpxmlcharrefreplace)_file_templater_styles_legend make_tabler,r')r"rWrXfromdesctodescr`rrrps r make_fileHtmlDiff.make_files`&##d<<<<//)h*1"F '  6'. /w  @rc^U4SjnUVs/sH oC"U5PM nnUVs/sH oC"U5PM nnX4$s snfs snf)aReturns 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$)Nrr9 r)rs expandtabsrir)rr"s r expand_tabs2HtmlDiff._tab_newline_replace..expand_tabssS<<D)D??4==1D<<D)D<<S)006 6rr)r"rWrXrrs` r_tab_newline_replaceHtmlDiff._tab_newline_replacesM 74==94[&9 =189;t$9  >9s9>cU(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. Nr9rrrrr4r:>)r8r>rjcount _split_line) r" data_listline_numr@rzrr@rEmarkline1line2s rrHtmlDiff._split_lines)   h_ - 4y KdZZ%5a%78S@   h_ -   g!(w$QwQDQQQg!(RaR DLE4K%'E ()* 3u-rc#T# UHup#nUcX#U4v MX#supVupx//pURXU5 URXU5 U (d U (dMPU (aU RS5nOSnU (aU RS5nOSnX#U4v U (aMEU (aMNM g7f)z5Returns iterator that splits (wraps) mdiff text linesNr)rrr)rr_) r"diffsfromdatatodataflagfromlinefromtexttolinetotextfromlisttolists r _line_wrapperHtmlDiff._line_wrappers%* HD|d**2: / X!V   Xx 8   V6 2ff'||AH'H#ZZ]F%Fd**(ff%*sAB(AB(B(#B(c@///pCnUH^upVnURUR"SU/UQ765 URUR"SU/UQ765 URU5 M` X#U4$![a% URS5 URS5 NGf=f)zCollects 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"rrrflaglistrrrs r_collect_linesHtmlDiff._collect_lines.s$&b$) HD $ 1 1!D C( CD d//$??@ OOD !%*x''  $% d# $sAA..,BBc"SU-nSURU<U<S3nURSS5RSS5RS S 5nURS S 5R5nS U<SU<SU<S3$![a SnNof=f)zReturns 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&rz>z)_prefixrrsr)r"r>rlinenumr@ids rrHtmlDiff._format_lineCs WnG!%d!3GnFz2 No Differences Found z( Empty File z!fz#t)rr>r6r)r"rrrr`rrrnext_id next_hrefnum_chg in_changer r@rs r_convert_flagsHtmlDiff._convert_flagses<<?$s8}$DX& %)FA $IDQqzN+A!:h=O!OGJqLG&J!N+'+IO!" !*$wHdGIDPQ!%O$PP{>IIaL?8L x'99rc `UR5 URX5upU(aUnOSn[XXpRURS9nUR (aUR U5nURU5upn URXXU5uppn /nSn[[U 55HKnU UcUS:aURS5 M"M$URXUU 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$)aReturns 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). NrzV %s%s%s%s rz) z z!
z+%sz rrr4) data_rows header_rowrz+zz-zz^zr:zrr)rrrerkrlrjrrrrLr>r8_table_templaterrrrs)r"rWrXr{r|r`rr context_linesrrrrrrrfmtr@rrus rrzHtmlDiff.make_tables( !55iH  $M My#~~/   &&u-E$(#6#6u#= 6:5H5H HX6727 7s8}%A{"q5HHJK#IaL!+4Q<q !CCD& v3=H3=F HJ J$$tggaj!<<?($$ }}U#<=WU#<=WU#<=WT),WT(+  ,r)rlrkrrirj)rrrrF)rrrrrrwrxrryrrr#r}rrrrrrrrzrrrrr r s $NG%OGO4+""AC*+@8?@6!.5.n+8(*#. --:^INK,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 rr)r4rz)unknown delta choice (must be 1 or 2): %rNrr)intKeyErrorr)deltawhichr{prefixesrs rrrsv,.4 U,c{H 8x qr(N .D"#$)- ..sA5A AAAc4SSKnSSKnURU5$)Nr)doctestdifflibtestmod)rrs r_testrs ??7 ##r__main__)rg333333?)z )rrrrrrrrrr)rrrrr )&r__all__heapqrr collectionsr _namedtupletypesrr rrrrrr^r_matchrrrr rr rr rrerwrxrryobjectr rrrrrrrs8 >(1GZ( k 2k 2\.&bl!l!~  ::&67==! . -=?.2B%R =,.?CJ1XK"25?D6<(9#4J(,d%K\ ( 0 "],v],~ @$ z Gr