Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.media_type module

Provide media type handling utilities.

exception betty.media_type.InvalidMediaType

  Bases: `ValueError`

  Raised when an identifier is not a valid media type.

class betty.media_type.MediaType

  Bases: `object`

  Define a media type.

  Media types are also commonly known as content types or MIME types.

  __init__(media_type: str)
  property parameters: dict[str, str]

    The parameters, e.g. `{"charset": "UTF-8"}` for `"text/html; charset=UTF-8"`.

  property subtype: str

    The subtype, e.g. `"vnd.oasis.opendocument.text"` for `"application/vnd.oasis.opendocument.text"`.

  property subtypes: list[str]

    The subtype parts, e.g. `["vnd", "oasis", "opendocument", "text"]` for `"application/vnd.oasis.opendocument.text"`.

  property suffix: str | None

    The suffix, e.g. `json` for `application/ld+json`.

  property type: str

    The type, e.g. `application` for `application/ld+json`.