Skip to main content

Use rust infer crate to rewrite python-magic library

Project description

magic-rs

Package version Supported Python versions

Use rust infer crate to rewrite python-magic library


Installation

pip install magic-rs

Quickstart

from magic_rs import from_path, from_bytes

with open("testdata/sample.png", 'rb') as f:
    data = f.read()
    py_magic = from_bytes(data)
    print(py_magic.extension())
    print(py_magic.mime_type())
    print(py_magic.is_image())
    print(py_magic.is_app())
    print(py_magic.is_archive())
    print(py_magic.is_audio())
    print(py_magic.is_book())
    print(py_magic.is_document())
    print(py_magic.is_font())
    print(py_magic.is_video())
    print(py_magic.is_text())

py_magic = from_path("testdata/sample.png")
print(py_magic.extension())
print(py_magic.mime_type())
print(py_magic.is_image())

Benchmarks

For details, see benchmark.

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

magic_rs-0.1.0.tar.gz (17.8 kB view hashes)

Uploaded Source

Built Distributions

magic_rs-0.1.0-pp39-pypy39_pp73-win_amd64.whl (150.4 kB view hashes)

Uploaded PyPy Windows x86-64

magic_rs-0.1.0-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl (399.4 kB view hashes)

Uploaded PyPy musllinux: musl 1.1+ x86-64

magic_rs-0.1.0-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl (399.8 kB view hashes)

Uploaded PyPy musllinux: musl 1.1+ ARM64

magic_rs-0.1.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (228.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

magic_rs-0.1.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (218.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

magic_rs-0.1.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl (200.3 kB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

magic_rs-0.1.0-pp39-pypy39_pp73-macosx_10_7_x86_64.whl (215.6 kB view hashes)

Uploaded PyPy macOS 10.7+ x86-64

magic_rs-0.1.0-pp38-pypy38_pp73-musllinux_1_1_x86_64.whl (399.1 kB view hashes)

Uploaded PyPy musllinux: musl 1.1+ x86-64

magic_rs-0.1.0-pp38-pypy38_pp73-musllinux_1_1_aarch64.whl (399.8 kB view hashes)

Uploaded PyPy musllinux: musl 1.1+ ARM64

magic_rs-0.1.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (228.1 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

magic_rs-0.1.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (218.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

magic_rs-0.1.0-cp311-none-win_amd64.whl (150.4 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

magic_rs-0.1.0-cp311-cp311-musllinux_1_1_x86_64.whl (399.5 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

magic_rs-0.1.0-cp311-cp311-musllinux_1_1_aarch64.whl (400.1 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ ARM64

magic_rs-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (228.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

magic_rs-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (218.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

magic_rs-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (200.4 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

magic_rs-0.1.0-cp311-cp311-macosx_10_7_x86_64.whl (215.6 kB view hashes)

Uploaded CPython 3.11 macOS 10.7+ x86-64

magic_rs-0.1.0-cp310-none-win_amd64.whl (150.4 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

magic_rs-0.1.0-cp310-cp310-musllinux_1_1_x86_64.whl (399.5 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

magic_rs-0.1.0-cp310-cp310-musllinux_1_1_aarch64.whl (400.1 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ ARM64

magic_rs-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (228.4 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

magic_rs-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (218.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

magic_rs-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (200.4 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

magic_rs-0.1.0-cp310-cp310-macosx_10_7_x86_64.whl (215.6 kB view hashes)

Uploaded CPython 3.10 macOS 10.7+ x86-64

magic_rs-0.1.0-cp39-none-win_amd64.whl (150.6 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

magic_rs-0.1.0-cp39-cp39-musllinux_1_1_x86_64.whl (399.8 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

magic_rs-0.1.0-cp39-cp39-musllinux_1_1_aarch64.whl (400.3 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ ARM64

magic_rs-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (228.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

magic_rs-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (219.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

magic_rs-0.1.0-cp39-cp39-macosx_11_0_arm64.whl (200.6 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

magic_rs-0.1.0-cp39-cp39-macosx_10_7_x86_64.whl (215.8 kB view hashes)

Uploaded CPython 3.9 macOS 10.7+ x86-64

magic_rs-0.1.0-cp38-none-win_amd64.whl (150.5 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

magic_rs-0.1.0-cp38-cp38-musllinux_1_1_x86_64.whl (399.8 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

magic_rs-0.1.0-cp38-cp38-musllinux_1_1_aarch64.whl (400.4 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ ARM64

magic_rs-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (228.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

magic_rs-0.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (219.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

magic_rs-0.1.0-cp38-cp38-macosx_11_0_arm64.whl (200.7 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

magic_rs-0.1.0-cp38-cp38-macosx_10_7_x86_64.whl (215.8 kB view hashes)

Uploaded CPython 3.8 macOS 10.7+ x86-64

Supported by

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