# Path: meld/matchers.py
# def init_worker():
# def matcher_worker(text1, textn):
# def find_common_prefix(a, b):
# def find_common_suffix(a, b):
#     def __init__(self, isjunk=None, a="", b=""):
#     def get_matching_blocks(self):
#     def get_opcodes(self):
#     def get_difference_opcodes(self):
#     def preprocess_remove_prefix_suffix(self, a, b):
#     def preprocess_discard_nonmatching_lines(self, a, b):
#         def index_matching(a, b):
#     def preprocess(self):
#     def postprocess(self):
#     def build_matching_blocks(self, lastsnake):
#     def initialise(self):
#     def preprocess_discard_nonmatching_lines(self, a, b):
#         def index_matching_kmers(a, b):
#     def __init__(self, isjunk=None, a="", b="", syncpoints=None):
#     def initialise(self):
# class MyersSequenceMatcher(difflib.SequenceMatcher):
# class InlineMyersSequenceMatcher(MyersSequenceMatcher):
# class SyncPointMyersSequenceMatcher(MyersSequenceMatcher):


import gobject
from .matchers import DiffChunk, MyersSequenceMatcher, \
    SyncPointMyersSequenceMatcher

    def sequences_identical(self):
        # check so that we don't call an uninitialised comparison 'identical'
        return self.diffs == [[], []] and self._initialised

    def _merge_blocks(self, using):
        LO, HI = 1, 2
        lowc = min(using[0][0][LO], using[1][0][LO])
        highc = max(using[0][-1][HI], using[1][-1][HI])
        low = []
        high = []
        for i in (0, 1):
            d = using[i][0]
            low.append(lowc - d[LO] + d[2 + LO])
            d = using[i][-1]
            high.append(highc - d[HI] + d[2 + HI])
        return low[0], high[0], lowc, highc, low[1], high[1]

    def _auto_merge(self, using, texts):
        """Automatically merge two sequences of change blocks"""
        l0, h0, l1, h1, l2, h2 = self._merge_blocks(using)
        if h0 - l0 == h2 - l2 and texts[0][l0:h0] == texts[2][l2:h2]:
            if l1 != h1 and l0 == h0:
                tag = "delete"
            elif l1 != h1:
                tag = "replace"
            else:
                tag = "insert"
        else:
            tag = "conflict"

# Path: meld/matchers.py
# def init_worker():
# def matcher_worker(text1, textn):
# def find_common_prefix(a, b):
# def find_common_suffix(a, b):
#     def __init__(self, isjunk=None, a="", b=""):
#     def get_matching_blocks(self):
#     def get_opcodes(self):
#     def get_difference_opcodes(self):
#     def preprocess_remove_prefix_suffix(self, a, b):
#     def preprocess_discard_nonmatching_lines(self, a, b):
#         def index_matching(a, b):
#     def preprocess(self):
#     def postprocess(self):
#     def build_matching_blocks(self, lastsnake):
#     def initialise(self):
#     def preprocess_discard_nonmatching_lines(self, a, b):
#         def index_matching_kmers(a, b):
#     def __init__(self, isjunk=None, a="", b="", syncpoints=None):
#     def initialise(self):
# class MyersSequenceMatcher(difflib.SequenceMatcher):
# class InlineMyersSequenceMatcher(MyersSequenceMatcher):
# class SyncPointMyersSequenceMatcher(MyersSequenceMatcher):


# Path: meld/diffutil.py
import gobject
from .matchers import DiffChunk, MyersSequenceMatcher, \
    SyncPointMyersSequenceMatcher


    def sequences_identical(self):
        # check so that we don't call an uninitialised comparison 'identical'
        return self.diffs == [[], []] and self._initialised

    def _merge_blocks(self, using):
        LO, HI = 1, 2
        lowc = min(using[0][0][LO], using[1][0][LO])
        highc = max(using[0][-1][HI], using[1][-1][HI])
        low = []
        high = []
        for i in (0, 1):
            d = using[i][0]
            low.append(lowc - d[LO] + d[2 + LO])
            d = using[i][-1]
            high.append(highc - d[HI] + d[2 + HI])
        return low[0], high[0], lowc, highc, low[1], high[1]

    def _auto_merge(self, using, texts):
        """Automatically merge two sequences of change blocks"""
        l0, h0, l1, h1, l2, h2 = self._merge_blocks(using)
        if h0 - l0 == h2 - l2 and texts[0][l0:h0] == texts[2][l2:h2]:
            if l1 != h1 and l0 == h0:
                tag = "delete"
            elif l1 != h1:
                tag = "replace"
            else:
                tag = "insert"
        else:
            tag = "conflict"

        out0 = DiffChunk._make((tag, l1, h1, l0, h0))