mimelib 🙊
A MIME type is a label used to identify a type of data. It is used so software can know how to handle the data. It serves the same purpose on the Internet that file extensions do on Microsoft Windows. — Quentin
mimelib aims at working with MIME types easier in Python. The standard library comes with the mimetypes
module. This library builds on top of it and adds more niceties to it, so you're generally happier when working with MIME types today.
>>> import mimelib
>>> mimelib.mimetype('application/json').is_text
True
>>> mimelib.url('https://example.com/avatar.jpg').is_image
True
>>> mimelib.url('pianoman.mp3').file_type
media
Installation
To install mimelib, use pipenv (or pip):
$ pipenv install mimelib
Usage
mimelib is intended to be used alongside the mimetypes standard library
module, and builds on top of it under the hood. So, if you are adding additional
MIME types to be recognized, mimelib will work just as fine.
Initialization
Either a valid MIME type string, or a URL or path can be used to work with mimelib.
>>> m1 = mimelib.mimetype("application/json") # pass a valid MIME type
>>> m2 = mimelib.url("foo/bar/dataset.csv") # or pass a path / url
Both these methods return a MIME object, the various useful properties of which
are listed below.
Getting the file type
The following file types are reported: text, image, media and binary.
>>> mimelib.mimetype("application/ecmascript").file_type
text
>>> mimelib.mimetype("video/mpeg").file_type
media
>>> mimelib.url("archive.rar").file_type
binary
The Mime object also has the following properties for conveniently checking
specific file types:
is_textis_imageis_mediais_binary
Metadata
Release files for mimelib 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mimelib-0.1.1.tar.gz | 5.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mimelib-0.1.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 10.0 kB
Release files / mimelib-0.1.1.tar.gz
| Download URL | mimelib-0.1.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b36a5337ff7a8f31e5d5fbb8da17cc1debe299297df002cdfe12f5ae5e0f468
|
|
BLAKE2b-256 checksum How to use checksums |
777fda82188fb6d0e279734ca5185d1b509c166ae8d6f8b825ea325615ca5eb5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / mimelib-0.1.1-py2.py3-none-any.whl
| Download URL | mimelib-0.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
70607238b57b1411d5bfc68661885f81ac00127d22bdaf71a1c857005693934b
|
|
BLAKE2b-256 checksum How to use checksums |
b1a96b2ca090da519f1b22831e9f3fa3bb9634c3fdcb304323e01134feddb58a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for mimelib 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.