Metadata-Version: 2.4
Name: pantomime
Version: 0.6.1
Summary: MIME type normalisation and labels.
Home-page: http://github.com/alephdata/pantomime
Author: Journalism Development Network, Inc.
Author-email: data@occrp.org
License: MIT
Keywords: mime mimetypes file types
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: banal>=0.3.5
Requires-Dist: normality>=0.5.6
Provides-Extra: dev
Requires-Dist: banal; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: coverage>=4.1; extra == "dev"
Requires-Dist: flake8>=2.6.0; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: wheel>=0.29.0; extra == "dev"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: summary

# pantomime

[![build](https://github.com/alephdata/pantomime/actions/workflows/build.yml/badge.svg)](https://github.com/alephdata/pantomime/actions/workflows/build.yml)

``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:

```python
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:

```python
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.
