Skip to main content

Use rust infer crate to rewrite python-magic library

Project description

magic-rs

Package version Supported Python versions

Python wrapper for Rust infer crate


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.2.0.tar.gz (8.7 kB view hashes)

Uploaded Source

Built Distributions

magic_rs-0.2.0-pp310-pypy310_pp73-win_amd64.whl (146.1 kB view hashes)

Uploaded PyPy Windows x86-64

magic_rs-0.2.0-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl (419.6 kB view hashes)

Uploaded PyPy musllinux: musl 1.1+ x86-64

magic_rs-0.2.0-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl (421.1 kB view hashes)

Uploaded PyPy musllinux: musl 1.1+ ARM64

magic_rs-0.2.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (247.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

magic_rs-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (240.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

magic_rs-0.2.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl (207.0 kB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

magic_rs-0.2.0-pp310-pypy310_pp73-macosx_10_12_x86_64.whl (216.3 kB view hashes)

Uploaded PyPy macOS 10.12+ x86-64

magic_rs-0.2.0-pp39-pypy39_pp73-win_amd64.whl (146.1 kB view hashes)

Uploaded PyPy Windows x86-64

magic_rs-0.2.0-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl (419.6 kB view hashes)

Uploaded PyPy musllinux: musl 1.1+ x86-64

magic_rs-0.2.0-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl (421.1 kB view hashes)

Uploaded PyPy musllinux: musl 1.1+ ARM64

magic_rs-0.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (247.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

magic_rs-0.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (240.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

magic_rs-0.2.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl (206.9 kB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

magic_rs-0.2.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl (216.3 kB view hashes)

Uploaded PyPy macOS 10.12+ x86-64

magic_rs-0.2.0-pp38-pypy38_pp73-win_amd64.whl (146.1 kB view hashes)

Uploaded PyPy Windows x86-64

magic_rs-0.2.0-pp38-pypy38_pp73-musllinux_1_1_x86_64.whl (419.8 kB view hashes)

Uploaded PyPy musllinux: musl 1.1+ x86-64

magic_rs-0.2.0-pp38-pypy38_pp73-musllinux_1_1_aarch64.whl (421.0 kB view hashes)

Uploaded PyPy musllinux: musl 1.1+ ARM64

magic_rs-0.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (247.3 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

magic_rs-0.2.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (240.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

magic_rs-0.2.0-cp312-none-win_amd64.whl (145.6 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

magic_rs-0.2.0-cp312-cp312-musllinux_1_1_x86_64.whl (418.9 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ x86-64

magic_rs-0.2.0-cp312-cp312-musllinux_1_1_aarch64.whl (420.5 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ ARM64

magic_rs-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (246.4 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

magic_rs-0.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (239.6 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

magic_rs-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (206.5 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

magic_rs-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl (215.4 kB view hashes)

Uploaded CPython 3.12 macOS 10.12+ x86-64

magic_rs-0.2.0-cp311-none-win_amd64.whl (146.7 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

magic_rs-0.2.0-cp311-cp311-musllinux_1_1_x86_64.whl (420.1 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

magic_rs-0.2.0-cp311-cp311-musllinux_1_1_aarch64.whl (421.8 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ ARM64

magic_rs-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (247.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

magic_rs-0.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (240.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

magic_rs-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (207.5 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

magic_rs-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl (216.8 kB view hashes)

Uploaded CPython 3.11 macOS 10.12+ x86-64

magic_rs-0.2.0-cp310-none-win_amd64.whl (146.6 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

magic_rs-0.2.0-cp310-cp310-musllinux_1_1_x86_64.whl (420.1 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

magic_rs-0.2.0-cp310-cp310-musllinux_1_1_aarch64.whl (421.8 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ ARM64

magic_rs-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (247.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

magic_rs-0.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (240.4 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

magic_rs-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (207.4 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

magic_rs-0.2.0-cp310-cp310-macosx_10_12_x86_64.whl (216.8 kB view hashes)

Uploaded CPython 3.10 macOS 10.12+ x86-64

magic_rs-0.2.0-cp39-none-win_amd64.whl (146.8 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

magic_rs-0.2.0-cp39-cp39-musllinux_1_1_x86_64.whl (420.4 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

magic_rs-0.2.0-cp39-cp39-musllinux_1_1_aarch64.whl (421.9 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ ARM64

magic_rs-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (247.9 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

magic_rs-0.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (240.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

magic_rs-0.2.0-cp39-cp39-macosx_11_0_arm64.whl (207.6 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

magic_rs-0.2.0-cp39-cp39-macosx_10_12_x86_64.whl (217.0 kB view hashes)

Uploaded CPython 3.9 macOS 10.12+ x86-64

magic_rs-0.2.0-cp38-none-win_amd64.whl (146.7 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

magic_rs-0.2.0-cp38-cp38-musllinux_1_1_x86_64.whl (420.3 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

magic_rs-0.2.0-cp38-cp38-musllinux_1_1_aarch64.whl (421.9 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ ARM64

magic_rs-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (247.8 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

magic_rs-0.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (240.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

magic_rs-0.2.0-cp38-cp38-macosx_11_0_arm64.whl (207.5 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

magic_rs-0.2.0-cp38-cp38-macosx_10_12_x86_64.whl (216.8 kB view hashes)

Uploaded CPython 3.8 macOS 10.12+ 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