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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-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.36-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 12ed758b6656c53c41196d7d4464ca7fd5fb37ea287acd7d5aa80feefec11954
MD5 0ca5d34daf47d1fa39b99b5d7375c26e
BLAKE2b-256 f3c7626c764d1d3ee808c935d9d07e560e4205e6ac63e94d457fa9e60b8454c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.36-cp314-cp314-macosx_10_15_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 1ebb42dee72c9e5fb1d365a0a1b8cb24550f0c82e886954bb6c0e00d7877d712
MD5 bd5eb7e6ceac928b8f3b4c6df685650d
BLAKE2b-256 e6e6ffa6c8d69a21b16880b440f72b5eb89eef42bf57b5e9d53cdba15eb31bb1

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.36-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.36-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 89a1e5d955eb9f03d5719740b7a63bb428d94ea1e30c43d019b7227eaefbe9ca
MD5 9d2bc76fa2b9083d9b49f91594a1ac0a
BLAKE2b-256 4a9af1a699d79e91929a3d5f8d08c29c479346ab21c8d24a98c23ab9e9afc3f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.36-cp313-cp313-macosx_10_13_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 5df497fb67ac3554a6b41117029186f394b223ee892570cbd3600468749ec5bb
MD5 702c4f6c489daf47f5c5aa637289535c
BLAKE2b-256 2f499d263a0b6f86b7ad259d1ea0580bb66d2506d71524025aff98decff1d2b5

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.36-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.36-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3d3004ee68eed8df5cf04405ad2885a532c68776499801fb742565185fb2f07c
MD5 572b3b5fb0c4cf0e7fdebd6001a79d85
BLAKE2b-256 53b983304cca9d68d112941f53639859f1bcf815d51733991fdf0cd9cf35a363

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.36-cp312-cp312-macosx_10_13_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c8d4cc4f558ce38794c9f2a221471bbf2fc7a7e26b3df623ee3d7a58bb49b7be
MD5 d1556dd767898b4d7ce9aac60c25f124
BLAKE2b-256 34ed44471de685c5e9e8dc049bf31ef513d6c1b1cb8f59ef7f10c16656534bbb

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.36-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.36-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8b83379b257b893e2a27cb2bd3abaeabca0cdeaf40f5ca895f6ef48c4e93861a
MD5 cd6c54a484d9d87c3402287ad7d612b5
BLAKE2b-256 1c4f3852fdf4ad3db0694e435846c7d28039b5355b19910c7fa9d80dde465472

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.36-cp311-cp311-macosx_10_9_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 511685c7438213f4679d7aec930f10b33232effd64e1c1b8998febf6dc129efe
MD5 7ecfa5c67a06e8045a030958f712ab49
BLAKE2b-256 a408b7ff354efd14b4c3fb1ccc801e93a55667f173c4820f485b1ebdc87ba1e9

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.36-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.36-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 41d6d16961f3f6d6e83d47a7cea70588782a63a7ec05701af195db29524cc63d
MD5 351ed98d426680a82b9d4c64f9bf1ac0
BLAKE2b-256 6ee8fdf97688697015bc0873632dd075291c56d0ae467cbb87c7569328c3f7fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for actrecipemagicfile-0.4.36-cp310-cp310-macosx_10_9_x86_64.macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 9886a205deb6104bd661529c86956654a1eed8dff697157d0551b9ebb3e74be7
MD5 4c6899f96fca0a59f290a6f30a751c80
BLAKE2b-256 4d41265e75eec775c0c77c0fcd6c1f147498828c23b0834d6932610914e5955d

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.36-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.36-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 78056d43bae66c293405e99c80c7940e5031d9e699540dce39abc462a8d0d009
MD5 e21d9d75c6c9d9f293e9d8d4ec91002d
BLAKE2b-256 ebda35ab3ab1e62bce411f93d7768ac9a389f613ccf05a98aa39ce646eb9a7be

See more details on using hashes here.

File details

Details for the file actrecipemagicfile-0.4.36-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.36-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3faab8bac0a0036b6d3343e7d8ddc0b4b2fec165e62206ad3d075f5c6a43eeff
MD5 49c7b4c91d4b1d0cb0ad79c9b46e61bf
BLAKE2b-256 1dcc3014d4e3f0bc7866a7e80732a443921ba68f5a2410cb02db246d21c64c0a

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