superdiff API¶
superdiff.Differ¶
-
class
Differ(ignore_case=False, ignore_non_newline_whitespace=False, ignore_non_newline_whitespace_changes=False, ignore_newline_changes=False, ignore_blank_lines=False, ignore_leading_whitespace=False, ignore_trailing_whitespace=False)[source]¶ This class can be used to flexibly compare two pieces of text and return diff information in a variety of formats.
Definitions of common terms used:
- non-newline whitespace: Tabs and spaces
- newline: Any of the following line endings:
\n,\r, or\r\n - whitespace: A combination of newlines and non-newline whitespace
- empty line: A line consisting of only whitespace
Return type: None-
__init__(ignore_case=False, ignore_non_newline_whitespace=False, ignore_non_newline_whitespace_changes=False, ignore_newline_changes=False, ignore_blank_lines=False, ignore_leading_whitespace=False, ignore_trailing_whitespace=False)[source]¶ Parameters: - ignore_case (
bool) – Ignore case differences between the two texts. - ignore_non_newline_whitespace (
bool) – Completely ignore differences in non-newline whitespace. - ignore_non_newline_whitespace_changes (
bool) – Treat consecutive sequences of non-newline whitespace as equal. For example, when this option is True, a single space, two spaces, a tab character, and a mix of tabs and spaces will be considered equal. - ignore_newline_changes (
bool) – Treat consecutive sequences of newline characters as equal. For example, when this option is True,\r,\r\r\n, and\n\nwill all be considered equal. - ignore_blank_lines (
bool) – Ignore lines consisting of only whitespace. - ignore_leading_whitespace (
bool) – Ignore whitespace characters at the beginning of lines. Note that this will cause empty lines to be treated as the empty string. - ignore_trailing_whitespace (
bool) – Ignore whitespace characters at the end of lines. Note that this will cause empty lines to be treated as the empty string.
Return type: None- ignore_case (
-
compare(first, second)[source]¶ Performs a line-by-line comparision of the strings first and second and returns a sequence of
(tag, left, right)tuples specifying the differences between the strings.tagcan be any of the values of “tag” used in https://docs.python.org/3.5/library/difflib.html#difflib.SequenceMatcher.get_opcodes and have the same meanings.If the two strings are equal, returns an empty iterable.
Return type: Iterable
superdiff.parser¶
-
class
Line(tokens, settings)[source]¶ Bases:
objectA line consists of a series of Tokens, with the final token being a NewlineToken.
Return type: None-
original_text¶
-
transformed_text¶
-
-
class
NewlineToken(regex_match, settings)[source]¶ Bases:
superdiff.parser.TokenA NewlineNode stores one or more newline characters.
Return type: None
-
class
Parser(ignore_case=False, ignore_non_newline_whitespace=False, ignore_non_newline_whitespace_changes=False, ignore_newline_changes=False, ignore_blank_lines=False, ignore_leading_whitespace=False, ignore_trailing_whitespace=False)[source]¶ Bases:
object
-
class
Token(regex_match, settings)[source]¶ Bases:
objectReturn type: None-
original_text¶
-
transformed_text¶
-
-
class
WhitespaceToken(regex_match, settings)[source]¶ Bases:
superdiff.parser.TokenAn InlineWhitespaceNode stores one or more non-newline whitespace characters (i.e. tabs and spaces).
Return type: None
-
class
WordToken(regex_match, settings)[source]¶ Bases:
superdiff.parser.TokenA WordToken stores a string of non-whitespace characters.
Return type: None