CFFI bindings for libmagic.
Project description
CFFI bindings for libmagic.
Free software: MIT License
Installation
pip install file
Usage
from file import Magic
with Magic() as magic:
print(magic.buffer("hello")) # => "text/plain"
from file import magic_buffer, magic_file, magic_setflags
magic = Magic()
mimetype = magic_buffer("\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
print(mimetype) # => "image/png"
mimetype = magic_file("/etc/passwd")
print(mimetype) # => "text/plain"
from file import MAGIC_NONE
magic_setflags(MAGIC_NONE)
mimetype = magic_file("demo.docx")
print(mimetype) # => "Microsoft Word 2007+"
magic.close() # don't forget about this
Changelog
0.1.0 (2017-11-02)
First release on PyPI.
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
file-0.2.1.tar.gz
(15.6 kB
view details)
File details
Details for the file file-0.2.1.tar.gz.
File metadata
- Download URL: file-0.2.1.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c75c70092d0505c19a3120cb4c35330ef28338b0ebd1a8ed2c82cf7ae44ce38b
|
|
| MD5 |
79d82f77672953b01db8e53d87360bd2
|
|
| BLAKE2b-256 |
f700e5142771067a769c205834273b66dc983b28e698a2bd82d35e75eab25dc7
|