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.37-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (640.8 kB view details)

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

actrecipemagicfile-0.4.37-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.37-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (640.8 kB view details)

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

actrecipemagicfile-0.4.37-cp313-cp313-macosx_10_13_x86_64.macosx_14_0_arm64.whl (408.4 kB view details)

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

actrecipemagicfile-0.4.37-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (640.8 kB view details)

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

actrecipemagicfile-0.4.37-cp312-cp312-macosx_10_13_x86_64.macosx_14_0_arm64.whl (407.0 kB view details)

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

actrecipemagicfile-0.4.37-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (640.5 kB view details)

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

actrecipemagicfile-0.4.37-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.37-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (640.5 kB view details)

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

actrecipemagicfile-0.4.37-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.37-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (640.5 kB view details)

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

actrecipemagicfile-0.4.37-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (640.4 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.37-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.37-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ee0dc47bc7244180b46a714de6f7ee949165f232bb71886680e9b0c824006da0
MD5 6aea3e249dd560a5276a19d4ef8268bf
BLAKE2b-256 dd3ae881e0f7124ac049cbe53718929957069c96f4ec9e78096a82881d65c0d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.37-cp314-cp314-macosx_10_15_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b3fdeaabc44dc641cf1c53522ae977aca19cb1c8f8233e8993c7bb1526a63354
MD5 71a7653e79fa27e55e1047376727fdc6
BLAKE2b-256 ba7f5ac06c7b92bc28c1b6d7c3f3fce3575a4fb80c4c1fb1076c6f4f645855e4

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.37-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.37-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 12b0df8cb7b1de607327dfb1e9ea861def89e53d086ab6ad07fa8f7d10f55225
MD5 7568b13bb5baa2cd16b4a85b826f09d3
BLAKE2b-256 3764f60f9924bcc6d7a8984e2ca7e92c87657d1962d0fcd1daab0cd1375b240a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.37-cp313-cp313-macosx_10_13_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6314f917c8bca835b77e19944d864b741889ab5812c27e7091285a5abdf573ee
MD5 47b20ff614ecb3dc31ea2fd7b7943f90
BLAKE2b-256 a52a830616f860b0957732d1aea90a208b010ae085eb21605fee01f746df7b36

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.37-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.37-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fc90f5e01e170bf933ff7d11be204a778ef2b4e75c12955ff7ee3f9e3e59a3ff
MD5 34246b8bfa8135cdd525da939cb73c00
BLAKE2b-256 1e5477c47b593b840fe8a3446ff7f5c38dc2535d9203a6520f3abadd110e4c1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.37-cp312-cp312-macosx_10_13_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e1923d8c9e4e92d3cfe83cf9482c539127486e78ea0a6ab5af8db19c2b1e64fb
MD5 bd58ec8339f9e458cfbf524814513d39
BLAKE2b-256 fdf26c1a8e5262997747fa05d73a138e5e23f8f74960fdf33cc3a5956712fd5b

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.37-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.37-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 50b7a378cfa88ebb2b67d88a16f2eeee22600e5335d5aa0381bb9e8d13109884
MD5 8d21ccee5de988df0d2e4e346e9b3c45
BLAKE2b-256 7dd4a25bcbfab0b5a22308e44c49a8b57bef485e2a057d61ad53c9f7cfc9d5a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.37-cp311-cp311-macosx_10_9_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a665a1057f0792f07319f7215adf173db8e20bac1d179f661b760c41a984603c
MD5 873027d4c3e64117c93e3c059480cedf
BLAKE2b-256 29d9dd5ea764cf0b5a4c0c5f7f4b9b3748bbe474d7219798c5feeaeececd9659

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.37-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.37-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2f835f632f77632c60f4b85f44fdf2c673ff580d951f3efc16b76ccff21f49db
MD5 fcdb70ef461b66c6d170eeb7801a47cd
BLAKE2b-256 ec09eb911fae1bc838cbef1a8feba773c65c78ec720acc0edb81452bdda24587

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.37-cp310-cp310-macosx_10_9_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f256e7c1332607a461f0cc1b557f90f956ce8b9d5673e292798bb7256ed360e0
MD5 caddfa482e8462bb4b954b23db3fe580
BLAKE2b-256 dc85e2480d1675a84c03f1250c15fcbbebc5fc346b4dadebe779cce8f3a767c0

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.37-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.37-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aaede68da1a0915f9caa8bfb674a122a0487138c1e854c5a5ad9f362bbac99a0
MD5 ff5cf5f267b445589975d60dd42e8c53
BLAKE2b-256 c16af56b996d2c7b3bdcb9a662a1677ec69cbd095cd9bc63ca3e561c06ba812c

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.37-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.37-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c6e8209a9f576c85ce88162ba447f7a8e02684202a793762b4446cc16bff55af
MD5 405a45a28853e93ed50706f13a0f2fdb
BLAKE2b-256 cfa629edc00d62c7fc93b17e3ca9a937abdf67e6f11aeed7b1e13697f3e03714

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