Utils Diff3
inyoka.utils.diff3
A diff3 algorithm implementation, based on the version of the MoinMoin wiki engine and some other diff/udiff stuff.
- copyright:
2007-2024 by the Inyoka Team, see AUTHORS for more details.
- copyright:
by Florian Festi.
- license:
BSD, see LICENSE for more details.
- exception inyoka.utils.diff3.DiffConflict(old_lineno, other_lineno, new_lineno)
Raised if a conflict occoured and the merging operated in non conflict mode.
- class inyoka.utils.diff3.DiffRenderer(udiff)
Give it a unified diff and it returns a list of the files that were mentioned in the diff together with a dict of meta information that can be used to render it in a HTML template.
- _chunk_re = re.compile('@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@')
- _extract_rev(line1, line2)
Extract the filename and revision hint from a line.
- _highlight_line(line, next)
Highlight inline changes in both lines.
- _parse_udiff()
Parse the diff an return data for the template.
- prepare()
Prepare the passed udiff for HTML rendering.
- inyoka.utils.diff3.find_match(list1, list2, nr1, nr2, mincount=3)
searches next matching pattern with lenght mincount if no pattern is found len of the both lists is returned
- inyoka.utils.diff3.generate_udiff(old, new, old_title='', new_title='', context_lines=4)
Generate an udiff out of two texts. If titles are given they will be used on the diff. context_lines defaults to 5 and represents the number of lines used in an udiff around a changed line.
- inyoka.utils.diff3.get_close_matches(name, matches, n=10, cutoff=0.6)
This is a replacement for a function in the difflib with the same name. The difference between the two implementations is that this one is case insensitive and optimized for page names.
- inyoka.utils.diff3.match(list1, list2, nr1, nr2, maxcount=3)
Return the number matching items after the given positions maximum maxcount lines are are processed. Unlike merge this only operates on lists.
- inyoka.utils.diff3.merge(old, other, new, allow_conflicts=True, markers=None)
Works like stream_merge but returns a string.
- inyoka.utils.diff3.prepare_udiff(udiff)
Prepare an udiff for the template. The Diff model uses this to render an udiff into a HTML table.
- inyoka.utils.diff3.process_line(line, start, end)
- inyoka.utils.diff3.stream_merge(old, other, new, allow_conflicts=True, markers=None)
Merges three strings or lists of lines. The return values is an iterator. Per default conflict markers are added to the source, you can however set :param allow_conflicts: to False which will get you a DiffConflict exception on the first encountered conflict.
- inyoka.utils.diff3.tripple_match(old, other, new, other_match, new_match)
Find next matching pattern unchanged in both other and new return the position in all three lists. Unlike merge this only operates on lists.