File type identification using libmagic
Project description
actrecipemagicfile (A CFFI fork of python-magic)
actrecipemagicfile
is a Python interface to the libmagic file type identification library. libmagic identifies file types by checking their headers against a predefined list. This functionality is accessible from the command line using the Unix command file
.
Usage
>>> import magicfile as magic
>>> magic.from_file("testdata/test.pdf")
'PDF document, version 1.2'
>>> magic.from_buffer(open("testdata/test.pdf").read(1024))
'PDF document, version 1.2'
>>> magic.from_file("testdata/test.pdf", mime=True)
'application/pdf'
There is also a Magic
class that provides more direct control,
including overriding the magic database file and turning on character
encoding detection. This is not recommended for general use. In
particular, it's not safe for sharing across multiple threads and
will fail throw if this is attempted.
>>> f = magic.Magic(uncompress=True)
>>> f.from_file('testdata/test.gz')
'ASCII text (gzip compressed data, was "test", last modified: Sat Jun 28
21:32:52 2008, from Unix)'
You can also combine the flag options:
>>> f = magic.Magic(mime=True, uncompress=True)
>>> f.from_file('testdata/test.gz')
'text/plain'
License
actrecipemagicfile
is distributed under the MIT license. See the included
LICENSE file for details.
Note: This package is mostly used in an internal project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file actrecipemagicfile-0.4.31-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: actrecipemagicfile-0.4.31-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 637.4 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4969576735cf415d9b1799e98f464993d98be2c2ef17042f7ea54a7bffdc046 |
|
MD5 | bc408fa856a9e7de92e80da20a94e30b |
|
BLAKE2b-256 | 09b0ec2351c091bcf4cf767e0034e22d4b81f870b2b535b547b42f487b9b6eb3 |
File details
Details for the file actrecipemagicfile-0.4.31-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: actrecipemagicfile-0.4.31-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 637.0 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 149e594f94d641f3f92abe20eeca1b9392a8d751b1559d9ee729c9b0419a4b4d |
|
MD5 | a7560bda142681a1445d6ddc17d2b4e9 |
|
BLAKE2b-256 | 2b98fb7d1abaedc076e1ac6ad5e4ffe8a7e34d5d3ae86ca21e1fed584057e9a6 |
File details
Details for the file actrecipemagicfile-0.4.31-cp311-cp311-macosx_10_9_universal2.whl
.
File metadata
- Download URL: actrecipemagicfile-0.4.31-cp311-cp311-macosx_10_9_universal2.whl
- Upload date:
- Size: 499.4 kB
- Tags: CPython 3.11, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2845daaaddc9e42cd8f865809728a1e183ab1bb42f54a6dd5261db71d253784 |
|
MD5 | 80e022d7a3885a1ad7c0a3de9c7f278b |
|
BLAKE2b-256 | bfebb80dcd1eb0b21897172902292358d2720a426c8f9144adb7a6399daa24b3 |
File details
Details for the file actrecipemagicfile-0.4.31-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: actrecipemagicfile-0.4.31-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 637.0 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59d39a7abac07b3978aa2ad483e984475fb99f0840b73f5eae5e6613e394a7e5 |
|
MD5 | 4449e49b2f1b1228509247db00244ba0 |
|
BLAKE2b-256 | 16b95ecd93d702d9c2f486c8b2f70af19a1cbdc044fb8568e539d03e2db82e07 |
File details
Details for the file actrecipemagicfile-0.4.31-cp310-cp310-macosx_11_0_x86_64.whl
.
File metadata
- Download URL: actrecipemagicfile-0.4.31-cp310-cp310-macosx_11_0_x86_64.whl
- Upload date:
- Size: 494.0 kB
- Tags: CPython 3.10, macOS 11.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7903a432934077ca6c0cece364d9aa78acda611ae2b6710e5f8ec2aa02fa3181 |
|
MD5 | c78be65b2fc3b88dfa3f256edf2cfe33 |
|
BLAKE2b-256 | b7b5da808ff7b89cab3fdb17da2a0f4e222173bf1f1473c8818993017dbae5ef |
File details
Details for the file actrecipemagicfile-0.4.31-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: actrecipemagicfile-0.4.31-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 637.0 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f1d930704d39b181ef8d0a77d7c9e9c794905e1d3abbc131150151d07e00f9b |
|
MD5 | ef8bc16068e5d873f3ea66a12f000a35 |
|
BLAKE2b-256 | d72ae8906fb8d497e37b61c617a6ef7d3d2e43da2421da9a78b2e5e08ab446c6 |
File details
Details for the file actrecipemagicfile-0.4.31-cp39-cp39-macosx_11_0_x86_64.whl
.
File metadata
- Download URL: actrecipemagicfile-0.4.31-cp39-cp39-macosx_11_0_x86_64.whl
- Upload date:
- Size: 494.0 kB
- Tags: CPython 3.9, macOS 11.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b82c707e9251cf42732615d945d113e70a05f7f4536d2dddb173eded744c55cb |
|
MD5 | a96eb07abf751b43c71e341b26a9b9fe |
|
BLAKE2b-256 | c44a60a0f50320edeb30e7b6f17cc0e441b6f660bf9e2f2315d780b9b95a9a1d |
File details
Details for the file actrecipemagicfile-0.4.31-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: actrecipemagicfile-0.4.31-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 637.1 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22a59f18fdee8cd56c74379ab62e9c37333845e1537b1713d5c0e5412e084a73 |
|
MD5 | f675506695f51558e48e8806d4b8eb13 |
|
BLAKE2b-256 | 70ed78c98fa983434d477264267a8a0f8c0fb2afeb0d79a489fbb5514050ab45 |
File details
Details for the file actrecipemagicfile-0.4.31-cp38-cp38-macosx_11_0_x86_64.whl
.
File metadata
- Download URL: actrecipemagicfile-0.4.31-cp38-cp38-macosx_11_0_x86_64.whl
- Upload date:
- Size: 494.0 kB
- Tags: CPython 3.8, macOS 11.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4276740224e42f5f4a63e9afd15bbec55a4f40036e89e1244d27bd9e9ea1b5c |
|
MD5 | 0bb0e9647227b7e15c37cdd1c2bae902 |
|
BLAKE2b-256 | d529be7651fa6078481f18da0697c2c69cc1c044afd726a23a15a313f00a6e1a |
File details
Details for the file actrecipemagicfile-0.4.31-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: actrecipemagicfile-0.4.31-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 636.9 kB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3810688b2150ffe26ef3fcf7128078a255d569e2878fe774e8227adf27756f0c |
|
MD5 | 14afe2635f3d2489ebef8484c68000f9 |
|
BLAKE2b-256 | a601495e944361cc48ab418a216b13d245ada183e12a16093366f5b82ecfdea2 |
File details
Details for the file actrecipemagicfile-0.4.31-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: actrecipemagicfile-0.4.31-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 636.9 kB
- Tags: CPython 3.6m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29494e6dccfb8dea55e5b9f549316173642239a98b01b2bb59ed7f9ac270b759 |
|
MD5 | e1f2ec116c646ff825be47b6ebc4aabc |
|
BLAKE2b-256 | 26625a0f8a2305526675976c5591c77a9b379d70751a9c86ccc34b06a81bbf95 |