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+Subtype
2 Type/_ +Subtype
1.9 Type/*
1.8 */Vendor+Subtype
1.7 */_ +Subtype
1.6 Type/_
1 */_
0.7
-
class
MimetypeHandler
(attachment, mimetype)[source]¶ Bases:
object
Handles 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.MimetypeHandler
Handles image mimetypes.
-
class
TextMimetype
(attachment, mimetype)[source]¶ Bases:
reviewboard.attachments.mimetypes.MimetypeHandler
Handles text mimetypes.
-
class
ReStructuredTextMimetype
(attachment, mimetype)[source]¶ Bases:
reviewboard.attachments.mimetypes.TextMimetype
Handles ReStructuredText (.rst) mimetypes.
-
class
MarkDownMimetype
(attachment, mimetype)[source]¶ Bases:
reviewboard.attachments.mimetypes.TextMimetype
Handle MarkDown (.md) mimetypes.