-ķ
ē¶<c      sĶ   d  k  l Z d d d d d g Z d f  d     YZ d d d	  Z d
   Z d f  d     YZ d k Z e i d  i	 d  Z
 d d  Z [ e
 e d  Z d   Z d   Z e d j o e   n d S(   (   s
   generatorss   get_close_matchess   ndiffs   restores   SequenceMatchers   Differc     s   t  Z d  Z e d d d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z RS(   sć  
    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 synching up on blocks of "junk lines", though (like blank lines in
    ordinary text files, or maybe "<P>" lines in HTML files).  That may be
    because this is the only method of the 3 that has a *concept* of
    "junk" <wink>.

    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 for 8 elements
    a[8] and b[17] match for 6 elements
    a[14] and b[23] match for 15 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:14] b[17:23]
     equal a[14:29] b[23: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.

    Methods:

    __init__(isjunk=None, a='', b='')
        Construct a SequenceMatcher.

    set_seqs(a, b)
        Set the two sequences to be compared.

    set_seq1(a)
        Set the first sequence to be compared.

    set_seq2(b)
        Set the second sequence to be compared.

    find_longest_match(alo, ahi, blo, bhi)
        Find longest matching block in a[alo:ahi] and b[blo:bhi].

    get_matching_blocks()
        Return list of triples describing matching subsequences.

    get_opcodes()
        Return list of 5-tuples describing how to turn a into b.

    ratio()
        Return a measure of the sequences' similarity (float in [0,1]).

    quick_ratio()
        Return an upper bound on .ratio() relatively quickly.

    real_quick_ratio()
        Return an upper bound on ratio() very quickly.
    s    c   s-   | |  _  t |  _ |  _ |  i | |  d S(   s[  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().
        N(   s   isjunks   selfs   Nones   as   bs   set_seqs(   s   selfs   isjunks   as   b(    (    s   /usr/lib/python2.2/difflib.pys   __init__ s     '	c   s   |  i |  |  i |  d S(   s   Set the two sequences to be compared.

        >>> s = SequenceMatcher()
        >>> s.set_seqs("abcd", "bcde")
        >>> s.ratio()
        0.75
        N(   s   selfs   set_seq1s   as   set_seq2s   b(   s   selfs   as   b(    (    s   /usr/lib/python2.2/difflib.pys   set_seqsĘ s     c   s5   | |  i  j o d Sn | |  _  t |  _ |  _ d S(   sM  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(   s   as   selfs   Nones   matching_blockss   opcodes(   s   selfs   a(    (    s   /usr/lib/python2.2/difflib.pys   set_seq1Ņ s
     	c   sH   | |  i  j o d Sn | |  _  t |  _ |  _ t |  _ |  i   d S(   sM  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(   s   bs   selfs   Nones   matching_blockss   opcodess
   fullbcounts   _SequenceMatcher__chain_b(   s   selfs   b(    (    s   /usr/lib/python2.2/difflib.pys   set_seq2ģ s     		c   så   |  i } h  |  _ } | i |  _ } xS t t |   D]? } | | } | |  o | | i	 |  n | g | | <q9 W|  i
 h  f \ } } | o= x6 | i   D]( } | |  o d | | <| | =n q„ Wn | i |  _ d  S(   Ni   (   s   selfs   bs   b2js   has_keys   b2jhass   xranges   lens   is   elts   appends   isjunks   junkdicts   keyss   isbjunk(   s   selfs   is   bs   b2js   junkdicts   b2jhass   elts   isjunk(    (    s   /usr/lib/python2.2/difflib.pys	   __chain_bs"    	 
 
c   s  |  i |  i |  i |  i f \ } } } } | | d f \ } } }
 h  } g  } xĖ t | |  D]ŗ } | i } h  }	 x | i | | |  D] } | | j  o q n | | j o Pn | | d d  d } |	 | <| |
 j o, | | d | | d | f \ } } }
 n q W|	 } q^ Wxu | | j o< | | j o/ | | | d  o | | d | | d j o( | d | d |
 d f \ } } }
 qWxc | |
 | j  o@ | |
 | j  o/ | | | |
  o | | |
 | | |
 j o |
 d }
 qW| | |
 f Sd S(   sČ  Find longest matching block in a[alo:ahi] and b[blo:bhi].

        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)
        (0, 4, 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)
        (1, 0, 4)

        If no blocks match, return (alo, blo, 0).

        >>> s = SequenceMatcher(None, "ab", "c")
        >>> s.find_longest_match(0, 2, 0, 1)
        (0, 0, 0)
        i    i   N(   s   selfs   as   bs   b2js   isbjunks   alos   blos   bestis   bestjs   bestsizes   j2lens   nothings   xranges   ahis   is   gets   j2lengets   newj2lens   js   bhis   k(   s   selfs   alos   ahis   blos   bhis   bestis   bs   bestjs   is   newj2lens   bestsizes   js   isbjunks   as   nothings   j2lengets   j2lens   ks   b2j(    (    s   /usr/lib/python2.2/difflib.pys   find_longest_match:s4    * * 	 0
	 L) Tc   s   |  i t j	 o |  i Sn g  |  _ t |  i  t |  i  f \ } } |  i d | d | |  i  |  i i	 | | d f  |  i Sd S(   sČ  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.

        The last triple is a dummy, (len(a), len(b), 0), and is the only
        triple with n==0.

        >>> s = SequenceMatcher(None, "abxcd", "abcd")
        >>> s.get_matching_blocks()
        [(0, 0, 2), (3, 2, 2), (5, 4, 0)]
        i    N(
   s   selfs   matching_blockss   Nones   lens   as   bs   las   lbs   _SequenceMatcher__helpers   append(   s   selfs   lbs   la(    (    s   /usr/lib/python2.2/difflib.pys   get_matching_blockss     	$c 
  sæ   |  i | | | |  \ } } }	 } |	 o | | j  o
 | | j  o |  i
 | | | | |  n | i |  | |	 | j  o | |	 | j  o% |  i
 | |	 | | |	 | |  n n d  S(   N(   s   selfs   find_longest_matchs   alos   ahis   blos   bhis   is   js   ks   xs   _SequenceMatcher__helpers   answers   append(
   s   selfs   alos   ahis   blos   bhis   answers   js   is   xs   k(    (    s   /usr/lib/python2.2/difflib.pys   __helperµs    %"c   s  |  i t j	 o |  i Sn d } } g  |  _ } xŻ |  i   D]Ļ \ } } } d } | | j  o
 | | j  o
 d } n/ | | j  o
 d } n | | j  o
 d } n | o  | i | | | | | f  n | | | | f \ } } | o  | i d | | | | f  n q? W| Sd S(   sZ  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)
        i    s    s   replaces   deletes   inserts   equalN(   s   selfs   opcodess   Nones   is   js   answers   get_matching_blockss   ais   bjs   sizes   tags   append(   s   selfs   answers   tags   bjs   is   js   ais   size(    (    s   /usr/lib/python2.2/difflib.pys   get_opcodesĮs(     
 


 $c   sA   t  d   |  i   d  } d | t |  i  t |  i  Sd S(   sŅ  Return 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
        c   s   |  | d S(   Ni’’’’(   s   sums   triple(   s   sums   triple(    (    s   /usr/lib/python2.2/difflib.pys   <lambda>s    i    f2.0N(   s   reduces   selfs   get_matching_blockss   matchess   lens   as   b(   s   selfs   matches(    (    s   /usr/lib/python2.2/difflib.pys   ratioųs     	c   s  |  i t j o? h  |  _ } x+ |  i D]  } | i | d  d | | <q' Wn |  i } h  } | i d f \ } } xg |  i
 D]\ } | |  o | | } n | i | d  } | d | | <| d j o | d } n q} Wd | t |  i
  t |  i  Sd S(   s©   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.
        i    i   f2.0N(   s   selfs
   fullbcounts   Nones   bs   elts   gets   avails   has_keys   availhass   matchess   as   numbs   len(   s   selfs   avails   numbs
   fullbcounts   availhass   matchess   elt(    (    s   /usr/lib/python2.2/difflib.pys   quick_ratios$     
 "	
 c   sA   t  |  i  t  |  i  f \ } } d t | |  | | Sd S(   sŹ   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().
        f2.0N(   s   lens   selfs   as   bs   las   lbs   min(   s   selfs   lbs   la(    (    s   /usr/lib/python2.2/difflib.pys   real_quick_ratio/s     $(   s   __name__s
   __module__s   __doc__s   Nones   __init__s   set_seqss   set_seq1s   set_seq2s   _SequenceMatcher__chain_bs   find_longest_matchs   get_matching_blockss   _SequenceMatcher__helpers   get_opcodess   ratios   quick_ratios   real_quick_ratio(    (    (    s   /usr/lib/python2.2/difflib.pys   SequenceMatcher s   l =			'	'	a			7		i   f0.59999999999999998c 	  s5  | d j o t d |   n d | j o
 d j n o t d |   n g  } t   } | i |   xq | D]i } | i
 |  | i   | j o# | i   | j o | i   | j o | i | i   | f  n qz W| i   | | } | i   g  i } | D] \ } } | |  q~ Sd S(   sĒ  Use 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']
    i    s   n must be > 0: f0.0f1.0s   cutoff must be in [0.0, 1.0]: N(   s   ns
   ValueErrors   cutoffs   results   SequenceMatchers   ss   set_seq2s   words   possibilitiess   xs   set_seq1s   real_quick_ratios   quick_ratios   ratios   appends   sorts   reverses   _[1]s   score(	   s   words   possibilitiess   ns   cutoffs   ss   scores   _[1]s   results   x(    (    s   /usr/lib/python2.2/difflib.pys   get_close_matches;s$     	 9!

 c   sP   d t  |   f \ } } x- | | j  o |  | | j o | d 7} q W| Sd S(   s}   
    Return number of `ch` characters at the start of `line`.

    Example:

    >>> _count_leading('   abc', ' ')
    3
    i    i   N(   s   lens   lines   is   ns   ch(   s   lines   chs   is   n(    (    s   /usr/lib/python2.2/difflib.pys   _count_leadingos      c     sS   t  Z d  Z e e d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(   se  
    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(1)
    >>> 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(1)

    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),
        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.

    Methods:

    __init__(linejunk=None, charjunk=None)
        Construct a text differencer, with optional filters.

    compare(a, b)
        Compare two sequences of lines; generate the resulting delta.
    c   s   | |  _  | |  _ d S(   s“  
        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 ('#').

        - `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!).
        N(   s   linejunks   selfs   charjunk(   s   selfs   linejunks   charjunk(    (    s   /usr/lib/python2.2/difflib.pys   __init__Üs     	c   #s  t  |  i | |  }
 xš |
 i   D]ā \ } } } } } | d j o" |  i | | | | | |  } n | d j o |  i d | | |  } na | d j o |  i d | | |  } n8 | d j o |  i d | | |  } n t d |  x | D]
 }	 |	 Vqö Wq" Wd	 S(
   sŲ  
        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 writeline()
        method of a file-like object.

        Example:

        >>> print ''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(1),
        ...                                'ore\ntree\nemu\n'.splitlines(1))),
        - one
        ?  ^
        + ore
        ?  ^
        - two
        - three
        ?  -
        + tree
        + emu
        s   replaces   deletes   -s   inserts   +s   equals    s   unknown tag N(   s   SequenceMatchers   selfs   linejunks   as   bs   crunchers   get_opcodess   tags   alos   ahis   blos   bhis   _fancy_replaces   gs   _dumps
   ValueErrors   line(   s   selfs   as   bs   alos   bhis   gs   ahis   blos   tags   lines   cruncher(    (    s   /usr/lib/python2.2/difflib.pys   comparešs       " c   #s0   x) t  | |  D] } d | | | f Vq Wd S(   s4   Generate comparison results for a same-tagged range.s   %s %sN(   s   xranges   los   his   is   tags   x(   s   selfs   tags   xs   los   his   i(    (    s   /usr/lib/python2.2/difflib.pys   _dumps      c   #s©   | | | | j  o4 |  i d | | |  }
 |  i d | | |  } n1 |  i d | | |  }
 |  i d | | |  } x) |
 | f D] } x | D]
 }	 |	 Vq Wq Wd  S(   Ns   +s   -(   s   bhis   blos   ahis   alos   selfs   _dumps   bs   firsts   as   seconds   gs   line(   s   selfs   as   alos   ahis   bs   blos   bhis   gs   seconds   lines   first(    (    s   /usr/lib/python2.2/difflib.pys   _plain_replaces       c   #sX  d d f \ } } t |  i  } t t f \ } } xń t	 | |  D]ą } | | }
 | i |
  xĄ t	 | |  D]Æ } | | } | |
 j o* | t j o | | f \ } } n qp n | i |  | i   | j o# | i   | j o | i   | j o" | i   | | f \ } } } n qp WqC W| | j  o^ | t j o5 x* |  i | | | | | |  D]
 } | Vq`Wd Sn | | d f \ } } } n t } x* |  i | | | | | |  D]
 } | Vq·W| | | | f \ }	 } | t j o+d } } | i" |	 |  xć | i#   D]Õ \ } } } } } | | | | f \ } } | d j o  | d | 7} | d | 7} nz | d j o | d	 | 7} n[ | d
 j o | d | 7} n< | d j o  | d | 7} | d | 7} n t+ d |  qWx$ |  i, |	 | | |  D]
 } | VqWn	 d |	 Vx2 |  i | | d | | | d |  D]
 } | VqFWd S(   s  
        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()
        >>> d._fancy_replace(['abcDefghiJkl\n'], 0, 1, ['abcdefGhijkl\n'], 0, 1)
        >>> print ''.join(d.results),
        - abcDefghiJkl
        ?    ^  ^  ^
        + abcdefGhijkl
        ?    ^  ^  ^
        f0.73999999999999999f0.75Nf1.0s    s   replaces   ^s   deletes   -s   inserts   +s   equals    s   unknown tag s     i   (-   s
   best_ratios   cutoffs   SequenceMatchers   selfs   charjunks   crunchers   Nones   eqis   eqjs   xranges   blos   bhis   js   bs   bjs   set_seq2s   alos   ahis   is   as   ais   set_seq1s   real_quick_ratios   quick_ratios   ratios   best_is   best_js   _plain_replaces   lines   _fancy_helpers   aelts   belts   atagss   btagss   set_seqss   get_opcodess   tags   ai1s   ai2s   bj1s   bj2s   las   lbs
   ValueErrors   _qformat(   s   selfs   as   alos   ahis   bs   blos   bhis   cutoffs   ais   aelts   bjs   btagss   tags   bj2s   bj1s   atagss   lines   best_is   best_js   lbs   las   is   js   ai1s   ai2s   eqis   eqjs
   best_ratios   belts   cruncher(    (    s   /usr/lib/python2.2/difflib.pys   _fancy_replace-sl      
 
9*  
  ' c 	  #s    g  } | | j  oK | | j  o" |  i | | | | | |  } n |  i	 d | | |  } n* | | j  o |  i	 d | | |  } n x | D]
 } | Vq Wd  S(   Ns   -s   +(   s   gs   alos   ahis   blos   bhis   selfs   _fancy_replaces   as   bs   _dumps   line(	   s   selfs   as   alos   ahis   bs   blos   bhis   gs   line(    (    s   /usr/lib/python2.2/difflib.pys   _fancy_helpers    " c   #s«   t  t | d  t | d   } t  | t | |  d   } | | i   } | | i   } d | V| o d d | | f Vn d | V| o d d | | f Vn d S(   s  
        Format "?" output and deal with leading tabs.

        Example:

        >>> d = Differ()
        >>> d._qformat('\tabcDefghiJkl\n', '\t\tabcdefGhijkl\n',
        ...            '  ^ ^  ^      ', '+  ^ ^  ^      ')
        >>> for line in d.results: print repr(line)
        ...
        '- \tabcDefghiJkl\n'
        '? \t ^ ^  ^\n'
        '+ \t\tabcdefGhijkl\n'
        '? \t  ^ ^  ^\n'
        s   	s    s   - s   ? %s%s
s   + N(   s   mins   _count_leadings   alines   blines   commons   atagss   rstrips   btags(   s   selfs   alines   blines   atagss   btagss   common(    (    s   /usr/lib/python2.2/difflib.pys   _qformats     (   s   __name__s
   __module__s   __doc__s   Nones   __init__s   compares   _dumps   _plain_replaces   _fancy_replaces   _fancy_helpers   _qformat(    (    (    s   /usr/lib/python2.2/difflib.pys   Differ~s   \ 	)			a	Ns	   \s*#?\s*$c   s   | |   t j	 Sd S(   sŅ   
    Return 1 for ignorable line: iff `line` is blank or contains a single '#'.

    Examples:

    >>> IS_LINE_JUNK('\n')
    1
    >>> IS_LINE_JUNK('  #   \n')
    1
    >>> IS_LINE_JUNK('hello\n')
    0
    N(   s   pats   lines   None(   s   lines   pat(    (    s   /usr/lib/python2.2/difflib.pys   IS_LINE_JUNKĪs     s    	c   s   |  | j Sd S(   sķ   
    Return 1 for ignorable character: iff `ch` is a space or tab.

    Examples:

    >>> IS_CHARACTER_JUNK(' ')
    1
    >>> IS_CHARACTER_JUNK('\t')
    1
    >>> IS_CHARACTER_JUNK('\n')
    0
    >>> IS_CHARACTER_JUNK('x')
    0
    N(   s   chs   ws(   s   chs   ws(    (    s   /usr/lib/python2.2/difflib.pys   IS_CHARACTER_JUNKŽs     c   s   t  | |  i |  |  Sd S(   sõ  
    Compare `a` and `b` (lists of strings); return a `Differ`-style delta.

    Optional keyword parameters `linejunk` and `charjunk` are for filter
    functions (or None):

    - linejunk: A function that should accept a single string argument, and
      return true iff the string is junk. The default is module-level function
      IS_LINE_JUNK, which filters out lines without visible characters, except
      for at most one splat ('#').

    - charjunk: A function that should accept a string of length 1. The
      default is module-level function IS_CHARACTER_JUNK, which filters out
      whitespace characters (a blank or tab; note: 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(1),
    ...              'ore\ntree\nemu\n'.splitlines(1))
    >>> print ''.join(diff),
    - one
    ?  ^
    + ore
    ?  ^
    - two
    - three
    ?  -
    + tree
    + emu
    N(   s   Differs   linejunks   charjunks   compares   as   b(   s   as   bs   linejunks   charjunk(    (    s   /usr/lib/python2.2/difflib.pys   ndiffņs    ! c   #s   y& h  d d <d d <t  |  } Wn  t j
 o t d |  n Xd | f } x+ |  D]# } | d  | j o | d Vn q\ Wd S(   s  
    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(1),
    ...              'ore\ntree\nemu\n'.splitlines(1))
    >>> diff = list(diff)
    >>> print ''.join(restore(diff, 1)),
    one
    two
    three
    >>> print ''.join(restore(diff, 2)),
    ore
    tree
    emu
    s   - i   s   + i   s)   unknown delta choice (must be 1 or 2): %rs     N(   s   ints   whichs   tags   KeyErrors
   ValueErrors   prefixess   deltas   line(   s   deltas   whichs   prefixess   tags   line(    (    s   /usr/lib/python2.2/difflib.pys   restores     & c    s#   d  k  }  d  k } |  i |  Sd  S(   N(   s   doctests   difflibs   testmod(   s   doctests   difflib(    (    s   /usr/lib/python2.2/difflib.pys   _test6s    s   __main__(   s
   __future__s
   generatorss   __all__s   SequenceMatchers   get_close_matchess   _count_leadings   Differs   res   compiles   matchs   IS_LINE_JUNKs   IS_CHARACTER_JUNKs   ndiffs   restores   _tests   __name__(   s   IS_CHARACTER_JUNKs   _count_leadings   Differs   __all__s   restores   _tests   ndiffs   res   IS_LINE_JUNKs
   generatorss   get_close_matchess   SequenceMatcher(    (    s   /usr/lib/python2.2/difflib.pys   ? s$    ’ ’ "4	’ O	$	 	