Lines Matching refs:self
120 def __init__(self, isjunk=None, a='', b='', autojunk=True):
173 # DON'T USE! Only __chain_b uses this. Use "in self.bjunk".
179 self.isjunk = isjunk
180 self.a = self.b = None
181 self.autojunk = autojunk
182 self.set_seqs(a, b)
184 def set_seqs(self, a, b):
193 self.set_seq1(a)
194 self.set_seq2(b)
196 def set_seq1(self, a):
217 if a is self.a:
219 self.a = a
220 self.matching_blocks = self.opcodes = None
222 def set_seq2(self, b):
243 if b is self.b:
245 self.b = b
246 self.matching_blocks = self.opcodes = None
247 self.fullbcount = None
248 self.__chain_b()
253 # when self.isjunk is defined, junk elements don't show up in this
266 def __chain_b(self):
277 b = self.b
278 self.b2j = b2j = {}
285 self.bjunk = junk = set()
286 isjunk = self.isjunk
295 self.bpopular = popular = set()
297 if self.autojunk and n >= 200:
305 def find_longest_match(self, alo=0, ahi=None, blo=0, bhi=None):
363 a, b, b2j, isbjunk = self.a, self.b, self.b2j, self.bjunk.__contains__
421 def get_matching_blocks(self):
440 if self.matching_blocks is not None:
441 return self.matching_blocks
442 la, lb = len(self.a), len(self.b)
454 i, j, k = x = self.find_longest_match(alo, ahi, blo, bhi)
489 self.matching_blocks = list(map(Match._make, non_adjacent))
490 return self.matching_blocks
492 def get_opcodes(self):
521 if self.opcodes is not None:
522 return self.opcodes
524 self.opcodes = answer = []
525 for ai, bj, size in self.get_matching_blocks():
547 def get_grouped_opcodes(self, n=3):
572 codes = self.get_opcodes()
597 def ratio(self):
619 matches = sum(triple[-1] for triple in self.get_matching_blocks())
620 return _calculate_ratio(matches, len(self.a) + len(self.b))
622 def quick_ratio(self):
632 if self.fullbcount is None:
633 self.fullbcount = fullbcount = {}
634 for elt in self.b:
636 fullbcount = self.fullbcount
641 for elt in self.a:
649 return _calculate_ratio(matches, len(self.a) + len(self.b))
651 def real_quick_ratio(self):
658 la, lb = len(self.a), len(self.b)
810 def __init__(self, linejunk=None, charjunk=None):
830 self.linejunk = linejunk
831 self.charjunk = charjunk
833 def compare(self, a, b):
859 cruncher = SequenceMatcher(self.linejunk, a, b)
862 g = self._fancy_replace(a, alo, ahi, b, blo, bhi)
864 g = self._dump('-', a, alo, ahi)
866 g = self._dump('+', b, blo, bhi)
868 g = self._dump(' ', a, alo, ahi)
874 def _dump(self, tag, x, lo, hi):
879 def _plain_replace(self, a, alo, ahi, b, blo, bhi):
884 first = self._dump('+', b, blo, bhi)
885 second = self._dump('-', a, alo, ahi)
887 first = self._dump('-', a, alo, ahi)
888 second = self._dump('+', b, blo, bhi)
893 def _fancy_replace(self, a, alo, ahi, b, blo, bhi):
915 cruncher = SequenceMatcher(self.charjunk)
945 yield from self._plain_replace(a, alo, ahi, b, blo, bhi)
957 yield from self._fancy_helper(a, alo, best_i, b, blo, best_j)
979 yield from self._qformat(aelt, belt, atags, btags)
985 yield from self._fancy_helper(a, best_i+1, ahi, b, best_j+1, bhi)
987 def _fancy_helper(self, a, alo, ahi, b, blo, bhi):
991 g = self._fancy_replace(a, alo, ahi, b, blo, bhi)
993 g = self._dump('-', a, alo, ahi)
995 g = self._dump('+', b, blo, bhi)
999 def _qformat(self, aline, bline, atags, btags):
1688 def __init__(self,tabsize=8,wrapcolumn=None,linejunk=None,
1700 self._tabsize = tabsize
1701 self._wrapcolumn = wrapcolumn
1702 self._linejunk = linejunk
1703 self._charjunk = charjunk
1705 def make_file(self, fromlines, tolines, fromdesc='', todesc='',
1724 return (self._file_template % dict(
1725 styles=self._styles,
1726 legend=self._legend,
1727 table=self.make_table(fromlines, tolines, fromdesc, todesc,
1732 def _tab_newline_replace(self,fromlines,tolines):
1746 line = line.expandtabs(self._tabsize)
1755 def _split_line(self,data_list,line_num,text):
1771 max = self._wrapcolumn
1808 self._split_line(data_list,'>',line2)
1810 def _line_wrapper(self,diffs):
1823 self._split_line(fromlist,fromline,fromtext)
1824 self._split_line(tolist,toline,totext)
1838 def _collect_lines(self,diffs):
1850 fromlist.append(self._format_line(0,flag,*fromdata))
1851 tolist.append(self._format_line(1,flag,*todata))
1859 def _format_line(self,side,flag,linenum,text):
1869 id = ' id="%s%s"' % (self._prefix[side],linenum)
1882 def _make_prefix(self):
1891 self._prefix = [fromprefix,toprefix]
1893 def _convert_flags(self,fromlist,tolist,flaglist,context,numlines):
1897 toprefix = self._prefix[1]
1940 def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False,
1960 self._make_prefix()
1964 fromlines,tolines = self._tab_newline_replace(fromlines,tolines)
1971 diffs = _mdiff(fromlines,tolines,context_lines,linejunk=self._linejunk,
1972 charjunk=self._charjunk)
1975 if self._wrapcolumn:
1976 diffs = self._line_wrapper(diffs)
1979 fromlist,tolist,flaglist = self._collect_lines(diffs)
1982 fromlist,tolist,flaglist,next_href,next_id = self._convert_flags(
2006 table = self._table_template % dict(
2009 prefix=self._prefix[1])