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.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: pantomime-0.5.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for pantomime-0.5.1.tar.gz
Algorithm Hash digest
SHA256 9696dd6fc0bd3c7571b68458513a72dfd02b07083388a6cc6529cbffbd0e8d87
MD5 07eed36da3d7888524201d36e92a084f
BLAKE2b-256 b2b3434065246a32b04b7f8a582c8e1d443d0bbc26f26a77c911e909d2e8cf4c

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: pantomime-0.5.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for pantomime-0.5.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0cd224e372252b4f95c37ea9aeb7da05bc5ec94b7356bd41bceb1252b5583bda
MD5 dffc67c467fe2e69664d3c7d36c4efb3
BLAKE2b-256 47132d266f9f6975f14b67b5301fc0f70eb428ad8a08f115e3c34d97e3b71cf0

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