reviewboard.diffviewer.parser¶
-
class
ParsedDiffFile
[source]¶ Bases:
object
A parsed file from a diff.
This stores information on a single file represented in a diff, including the contents of that file’s diff, as parsed by
DiffParser
or one of its subclasses.Parsers should set the attributes on this based on the contents of the diff, and should add any data found in the diff.
This class is meant to be used internally and by subclasses of
DiffParser
.-
data
[source]¶ The data for this diff.
This must be accessed after
finalize()
has been called.
-
finalize
()[source]¶ Finalize the parsed diff.
This makes the diff data available to consumers and closes the buffer for writing.
-
-
class
DiffParser
(data)[source]¶ Bases:
object
Parses diff files into fragments, taking into account special fields present in certain types of diffs.
-
parse
()[source]¶ Parses the diff, returning a list of File objects representing each file in the diff.
-
parse_change_header
(linenum)[source]¶ Parses part of the diff beginning at the specified line number, trying to find a diff header.
-
parse_special_header
(linenum, info)[source]¶ Parses part of a diff beginning at the specified line number, trying to find a special diff header. This usually occurs before the standard diff header.
The line number returned is the line after the special header, which can be multiple lines long.
-
parse_diff_header
(linenum, info)[source]¶ Parses part of a diff beginning at the specified line number, trying to find a standard diff header.
The line number returned is the line after the special header, which can be multiple lines long.
-
parse_after_headers
(linenum, info)[source]¶ Parses data after the diff headers but before the data.
By default, this does nothing, but a DiffParser subclass can override to look for special headers before the content.
-
raw_diff
(diffset)[source]¶ Returns a raw diff as a string.
The returned diff as composed of all FileDiffs in the provided diffset.
-