reviewboard.attachments.mimetypes¶
-
register_mimetype_handler(handler)[source]¶ Register a MimetypeHandler class.
This will register a Mimetype Handler used by Review Board to render thumbnails for the file attachements across different mimetypes.
Only MimetypeHandler subclasses are supported.
-
unregister_mimetype_handler(handler)[source]¶ Unregister a MimetypeHandler class.
This will unregister a previously registered mimetype handler.
Only MimetypeHandler subclasses are supported. The class must ahve been registered beforehand or a ValueError will be thrown.
-
score_match(pattern, mimetype)[source]¶ Return a score for how well the pattern matches the mimetype.
This is an ordered list of precedence (_ indicates non-match):
Format Precedence Type/Vendor+Subtype2 Type/_ +Subtype1.9 Type/*1.8 */Vendor+Subtype1.7 */_ +Subtype1.6 Type/_1 */_0.7
-
class
MimetypeHandler(attachment, mimetype)[source]¶ Bases:
objectHandles mimetype-specific properties.
This class also acts as a generic handler for mimetypes not matched explicitly by any handler. Note that this is not the same as ‘/’.
-
use_hd_thumbnails= True[source]¶ Subclasses (especially in extensions) can use this to introspect what size thumbnails they should generate.
-
classmethod
get_best_handler(mimetype)[source]¶ Return the handler and score that that best fit the mimetype.
-
classmethod
for_type(attachment)[source]¶ Return the handler that is the best fit for provided mimetype.
-
-
class
ImageMimetype(attachment, mimetype)[source]¶ Bases:
reviewboard.attachments.mimetypes.MimetypeHandlerHandles image mimetypes.
-
class
TextMimetype(attachment, mimetype)[source]¶ Bases:
reviewboard.attachments.mimetypes.MimetypeHandlerHandles text mimetypes.
-
class
ReStructuredTextMimetype(attachment, mimetype)[source]¶ Bases:
reviewboard.attachments.mimetypes.TextMimetypeHandles ReStructuredText (.rst) mimetypes.
-
class
MarkDownMimetype(attachment, mimetype)[source]¶ Bases:
reviewboard.attachments.mimetypes.TextMimetypeHandle MarkDown (.md) mimetypes.