reviewboard.diffviewer.opcode_generator¶
- class MoveRange(start, end, groups=[])¶
Bases:
object
Stores information on a move range.
This will store the start and end of the range, and all groups that are a part of it.
- __init__(start, end, groups=[])¶
- property last_group¶
- add_group(group, group_index)¶
- __repr__()¶
Return repr(self).
- class DiffOpcodeGenerator(differ, diff=None, interdiff=None, request=None, **kwargs)¶
Bases:
object
- ALPHANUM_RE = re.compile('\\w')¶
- WHITESPACE_RE = re.compile('\\s')¶
- MOVE_PREFERRED_MIN_LINES = 2¶
- MOVE_MIN_LINE_LENGTH = 20¶
- TAB_SIZE = 8¶
- __init__(differ, diff=None, interdiff=None, request=None, **kwargs)¶
Initialize the opcode generator.
Changed in version 3.0.18: Added the
request
and**kwargs
parameters.- Parameters:
differ (
reviewboard.diffviewer.differ.Differ
) – The differ being used to generate the diff.diff (
bytes
, optional) – The raw contents for the diff.interdiff (
bytes
, optional) – The raw contents for the diff on the other end of an interdiff range, if generating an interdiff.request (
django.http.HttpRequest
) – The HTTP request from the client.**kwargs (
dict
) – Additional keyword arguments, for future expansion.
- __iter__()¶
Returns opcodes from the differ with extra metadata.
This is a wrapper around a differ’s get_opcodes function, which returns extra metadata along with each range. That metadata includes information on moved blocks of code and whitespace-only lines.
This returns a list of opcodes as tuples in the form of (tag, i1, i2, j1, j2, meta).
- get_diff_opcode_generator_class()¶
Returns the DiffOpcodeGenerator class used for generating opcodes.
- set_diff_opcode_generator_class(renderer)¶
Sets the DiffOpcodeGenerator class used for generating opcodes.
- get_diff_opcode_generator(*args, **kwargs)¶
Returns a DiffOpcodeGenerator instance used for generating opcodes.