reviewboard.attachments.managers¶
Manager for FileAttachment objects.
- class FileAttachmentManager(*args, **kwargs)[source]¶
Bases:
Manager
Manages FileAttachment objects.
Adds utility functions for looking up FileAttachments based on other objects.
- create_from_filediff(filediff: FileDiff, from_modified: bool = True, save: bool = True, **kwargs) FileAttachment [source]¶
Create a new FileAttachment for a FileDiff.
FileAttachments created from a FileDiff are used to represent changes to binary files which would otherwise not be displayed with the diff.
An individual FileAttachment can represent either the original or modified copy of the file. If ‘from_modified’ is True, then the FileAttachment will be created using the information (filename, revision, etc.) for the modified version. If it is False, the FileAttachment will be created using the information for the original version.
- Parameters:
filediff (
reviewboard.diffviewer.models.filediff.FileDiff
) – The FileDiff to create the attachment for.from_modified (
bool
, optional) – Whether to create an attachment for the modified version of the file.save (
bool
, optional) – Whether to save the new object before returning.**kwargs (
dict
) – Additional keyword arguments to pass through to the FileAttachment model.
- Returns:
The newly-created file attachment.
- Return type:
- get_for_filediff(filediff: FileDiff, modified: bool = True) Optional[FileAttachment] [source]¶
Return the FileAttachment matching a FileDiff.
The FileAttachment associated with the path, revision and repository matching the DiffSet will be returned, if it exists.
It is up to the caller to check for errors.
- Parameters:
filediff (
reviewboard.diffviewer.models.FileDiff
) – The FileDiff to get the attachment for.modified (
bool
, optional) – IfTrue
, return the FileDiff corresponding to the modified revision. IfFalse
, return the FileDiff corresponding to the original revision.
- Returns:
The attachment for the given FileDiff, if one exists.
- Return type:
- __annotations__ = {}¶
- __slotnames__ = []¶