otupy.utils.media_types.MediaTypes
- class MediaTypes
Bases:
objectMedia type parsing and validation
This class extends the mediatype package with validation of Media Types. You can get the map of valid types from the types_map attribute, once a first update_iana_registry() is performed.
Methods
update_iana_registryValidates Media Type
Attributes
The map of media types found in the IANA registry
- types_map = []
The map of media types found in the IANA registry
- classmethod validate(name, syntax=True, iana_registry=True)
Validates Media Type
This method can validate both syntax and iana registration of media types. Media types are cached for improving performance, but they can be updated at any time through the registry_update method.
Note that if both validation options (syntax and iana_registry) are set to False, this method always returns True.
- Parameters:
name – The name to be validated as media type.
syntax – Check the name as a valid media type syntax (Default to True).
iana_registry – Check the name is registered in the IANA Media Type registry (Default to True).
- Returns:
True in case the name is valid according to the specific options (syntax and iana_registry).