madam.mime module

class madam.mime.MimeType(mediatype: Optional[Union[str, MimeType]], subtype: Optional[str] = None)[source]

Bases: object

Represents a MIME type according to RFC 2045. This class behaves identical to its string representation in dict and set.

Limitations:

  • Suffixes are considered a part of the subtype

  • Parameters like charset are not supported and will be treated as part of the subtype

__init__(mediatype: Optional[Union[str, MimeType]], subtype: Optional[str] = None)[source]

Initializes a new MIME type with either

  • both, media type and subtype strings

  • a complete MIME type string like 'audio/opus'

  • another MimeType object

Parameters
  • mediatype (str or MimeType or None) – Can define either the media type, or the complete MIME type by passing a MIME type string or another MimeType instance.

  • subtype (str or None) – Defines the subtype.