Skip to main content

File type identification using libmagic

Project description

actrecipemagicfile (A CFFI fork of python-magic)

PyPI version

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.

Changelog

[2024-12-04]

New: Added support for Mac Silicon (Python 3.10, 3.11).
New: Added support for Linux ARM (Python 3.10, 3.11, 3.12).

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.

Notes:

  • This package is primarily used in an internal project.
  • Support for Mac Silicon and Linux ARM is effective from 2024-12-04.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

actrecipemagicfile-0.4.38-cp314-cp314-win_amd64.whl (314.8 kB view details)

Uploaded CPython 3.14Windows x86-64

actrecipemagicfile-0.4.38-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (641.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

actrecipemagicfile-0.4.38-cp314-cp314-macosx_10_15_x86_64.macosx_14_0_arm64.whl (407.2 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64macOS 14.0+ ARM64

actrecipemagicfile-0.4.38-cp313-cp313-win_amd64.whl (337.2 kB view details)

Uploaded CPython 3.13Windows x86-64

actrecipemagicfile-0.4.38-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (641.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

actrecipemagicfile-0.4.38-cp313-cp313-macosx_10_13_x86_64.macosx_14_0_arm64.whl (407.0 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64macOS 14.0+ ARM64

actrecipemagicfile-0.4.38-cp312-cp312-win_amd64.whl (337.2 kB view details)

Uploaded CPython 3.12Windows x86-64

actrecipemagicfile-0.4.38-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (641.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

actrecipemagicfile-0.4.38-cp312-cp312-macosx_10_13_x86_64.macosx_14_0_arm64.whl (408.4 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64macOS 14.0+ ARM64

actrecipemagicfile-0.4.38-cp311-cp311-win_amd64.whl (337.1 kB view details)

Uploaded CPython 3.11Windows x86-64

actrecipemagicfile-0.4.38-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (641.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

actrecipemagicfile-0.4.38-cp311-cp311-macosx_10_9_x86_64.macosx_14_0_arm64.whl (407.1 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64macOS 14.0+ ARM64

actrecipemagicfile-0.4.38-cp310-cp310-win_amd64.whl (337.2 kB view details)

Uploaded CPython 3.10Windows x86-64

actrecipemagicfile-0.4.38-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (641.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

actrecipemagicfile-0.4.38-cp310-cp310-macosx_10_9_x86_64.macosx_14_0_arm64.whl (407.1 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64macOS 14.0+ ARM64

actrecipemagicfile-0.4.38-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (641.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

actrecipemagicfile-0.4.38-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (641.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file actrecipemagicfile-0.4.38-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 88e7ef557126d69a23ca6b7e7d195da92ab5ef034116b1239528f321a7995eb1
MD5 fd57de09f06b4ac714c77ebcbe3c0fb0
BLAKE2b-256 777add197c93b17d426c462ff78b0718d214a47126819dccc332ddb825203e1e

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 66f14c21ffefe3ea2ca8b3faba10cd8aea447c48f064f2ad401486ac2b99585f
MD5 9afdacc684c00454e2e4497e2779625f
BLAKE2b-256 a197f767ee1ee469d3e7f057b263cc4212e37836b47de56913e4d7d4c5c7440c

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp314-cp314-macosx_10_15_x86_64.macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp314-cp314-macosx_10_15_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7649fb785b387c8cd12d85a4e77573773933fc0c27e29f46e278d7950fc06ffa
MD5 4b7546a42da823332782c2dc6526eb67
BLAKE2b-256 3ce99cc8681f8429e19fc33508ee79271cfaaa09ba84086484de28959bd9722e

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d2ca15de17e9e4e57cef12e73bdf695cb3f35af5e3d4ef9ed3ad6aceb0b2a68d
MD5 19e15954e182421a4df895584ea1c1b7
BLAKE2b-256 69d15d8c14434e63a2455f2e1fabe337eb653cb528746a2f7fa9f89f2d44329a

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 99965edf563024236b15e27727e6c4eb3b458949269488a6d199811e27bb8d5c
MD5 f9722fa86407453eb5924e7b6834f719
BLAKE2b-256 12b283b39341238db981934ca5416daeb3e566f2794d0fcc9459f043183fa292

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp313-cp313-macosx_10_13_x86_64.macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp313-cp313-macosx_10_13_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 fdaa1f7cf672bf9ec4da22fca9edd12015f9d13052060bd21da2210c9b7a0df6
MD5 fe00df78f0d22a7c79b1116cf3f52877
BLAKE2b-256 16fbb567bddc345b31620a0d60af3958c710335a0f45b62f56cc204b92b7bd22

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fab7d3a7ea958c7dc0ab9da7196964cdcf22fd9c603414f295e86212b40901fd
MD5 023c42b0993ca598af27345c4a8da7d6
BLAKE2b-256 e0a94c4c1619eebcc3ffa01cade58de32a1aa96405b95d595ea6afd45171b5bf

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0da520769a46642f939e69383bb94a8cf4619263a861ceaacc0a4bdd7723b01f
MD5 8c5c01c7166fce68b529656795acc7d3
BLAKE2b-256 430921add115152d71aa816e83b88bfee6a3b9d6197cf69d07bf9487c4f37fbe

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp312-cp312-macosx_10_13_x86_64.macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp312-cp312-macosx_10_13_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a55d9035866fe4b51ad2438b84549da3b85021cb1e40d6043b5ebb509e16c11a
MD5 ecd9081cb777f62492b2dd106a7678a6
BLAKE2b-256 70f8481cee8c03300855dd994147e1aa44f8fc07c2d814eb7e890b762a68001e

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 949ef7f144bf833fdf1f4f34911d801499167ce8a755ed541e18a11fae441fe1
MD5 66ef18ae6bd49c783cd68917b202bc9b
BLAKE2b-256 c1c071909f76344ca4c6039c7de3ff546ff879ee7fc1387b224f5b222e9f4e07

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7ce2502878ea2f1e88baea1d42be8229755c45fb8b9a9005535d243835cab638
MD5 089ea190522945df04fd5ac4a03fbcd5
BLAKE2b-256 87c926eb0694d8055305f1f2429f9cb45c1e63c9decc57cd9481b7171e67f3fe

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp311-cp311-macosx_10_9_x86_64.macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp311-cp311-macosx_10_9_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 698d529dbc5178af75bf0015d9e02b353df1994255006e04156402b4687ffda4
MD5 be8165931a1c98b6d3c8cc1037bfbe06
BLAKE2b-256 03dd6ce1a9b7c3c4de07ca4d129a6f62d8d995fce6a70adc9ea2e903f2dc3027

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 316429699be2d82b403053f448f42c5ada1923c9ad1c431ba791bff33ebc658f
MD5 5d40fff5746aa422a71ed54a70822cad
BLAKE2b-256 0fe0d831da1f16f1f8770b4a92a789be870afe7cc49964ec4c63450fae92fc85

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7cfda4dfd2ca5302ca26611fe26650379b241dd3dfabd99b84f42fcd475f0043
MD5 ff790b77cdc85d0edfc83319dae3f29c
BLAKE2b-256 845065a5a56e8454cf8f1377f13f07a2676d46bb66cd327fd5b13ce5c1aa032c

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp310-cp310-macosx_10_9_x86_64.macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp310-cp310-macosx_10_9_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 d4feafa795bba7954c5a562aee0daaed03656db8f97671e35139db90ad5c6b07
MD5 8928793a4748d4b92f93e09d9fa02ced
BLAKE2b-256 1a79531a00a248df27174bbe669c33820ba6d7074dbf4e41398841edeee5790f

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3cc2c932c8ac75ad1de15afc95641151454c2258d287235c4d4855368d8f42cd
MD5 8855bc005ad835849f6985bd1fc92036
BLAKE2b-256 6b5f3b6b51e6364872760877e3f4b068c8acea81b5f279ae47f008b242f64483

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.38-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.38-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1dc167a846bc1ec0f3e6b8d689fcd9ab3c8737da83c58411c925b513637f28c8
MD5 ba3a73f9b281411b0c551b4957dfa137
BLAKE2b-256 5186a471119f8d80df3e41a91b7ddf0c6fd3796404d66bb8d241c471d340a03b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page