Skip to main content

MIME type normalisation and labels.

Project description

pantomime

build

pantomime is a small library that handles the parsing and normalisation of internet MIME types in Python. This can be useful to normalise invalid, or misformatted MIME types emitted by remote web servers.

Usage

The simplest use is to normalise a MIME type:

from pantomime import normalize_mimetype

assert normalize_mimetype('TEXT/PLAIN') == 'text/plain'
assert normalize_mimetype('plain/text') == 'text/plain'
assert normalize_mimetype(None) == 'application/octet-stream'
assert normalize_mimetype('') == 'application/octet-stream'

Internally, pantomime uses a MIMEType object to handle parsing. It can be used to access more specific information, like human readable labels:

from pantomime import parse_mimetype

parsed = parse_mimetype('text/plain')
assert parsed.family == 'text'
assert parsed.subtype == 'plain'
assert parsed.label == 'Plain text'

Open issues

  • Internationalisation, i.e. make the human-readable labels available in multiple languages.
  • Expand replacements for specific MIME types.

License

Licensed under MIT terms, see the LICENSE file included in this repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pantomime-0.5.3.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

pantomime-0.5.3-py2.py3-none-any.whl (9.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pantomime-0.5.3.tar.gz.

File metadata

  • Download URL: pantomime-0.5.3.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for pantomime-0.5.3.tar.gz
Algorithm Hash digest
SHA256 59ed03f51f27e600c5e10df183468b7619f3df905a1cdf876aa08a6b1f31a20b
MD5 fe502650039d49759314031a8036363e
BLAKE2b-256 138e3d3002fcbf4cfc8f12fd1d9b14373ffccc3323f3e04cb0a31b9cdccdf948

See more details on using hashes here.

Provenance

File details

Details for the file pantomime-0.5.3-py2.py3-none-any.whl.

File metadata

  • Download URL: pantomime-0.5.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for pantomime-0.5.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f93326f7dc3baed526b71abdfd3f65bfa7295281489751a37555cc95f917015f
MD5 1e91a93e5f9605986d9856455cd89f3e
BLAKE2b-256 e05b45d23efcd93aecb4cbefb9c194eb9c3c14b3ba9cdb7c66d94732d76c3ca6

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page