rp-libs / magic-rs

Python wrapper for Rust infer crate

Home Page:https://github.com/rp-libs/magic-rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Python wrapper for Rust infer crate

https://github.com/rp-libs/magic-rs

License:MIT License


Languages

Language:Python 88.6%Language:Rust 11.4%