Skip to content

v0.1.0

Latest

Choose a tag to compare

@thanos thanos released this 14 Nov 06:05

Python bindings for whiff. Point it at a file or at bytes and get one whiff/1 report: what the file is, where it came from, which rights apply, its hashes and risk signals, and a compact view of its content.

This release wraps crates.io whiff 0.8.0 with the common feature set. It does not reimplement extractors. The PyPI name whiff already belongs to an unrelated project, so the distribution is whiff-python. The import name is whiff.

Highlights

  • whiff.extract takes a path, bytes, or a binary file object and returns a dict. Problems inside a file stay in diagnostics. A path that cannot be inspected raises WhiffError. NotFoundError is also a FileNotFoundError; AccessError is also a PermissionError.
  • whiff.llm returns upstream Report::llm_view (1..100000 tokens, default 800).
  • whiff.extract_many keeps input order. on_error="collect" yields (path, report) or (path, error). on_error="halt" raises, and err.details["partial"] holds the pairs finished before the failure.
  • whiff.Engine holds native options and can be shared across threads. A process-wide semaphore (default 8 slots, 60s wait) bounds native calls. A waiter that times out raises OverloadedError.
  • Python Extractor and Analyzer classes patch the report after native extraction, in fallback, augment, or override mode. They do not enter the Rust registry, they do not run for embedded children, and llm does not run them. privacy="strict" scrubs plugin patches. Secrets are redacted either way.
  • stage="local" copies a regular file into a private scratch directory before taking a native slot, for a slow or network filesystem. The report still names the original path.

Install

pip install whiff-python==0.1.0
import whiff

report = whiff.extract("invoice.pdf")
report["identification"]["format"]  # "pdf"

view = whiff.llm("contract.pdf", tokens=800)

Python 3.11 or later. Wheels use PyO3's stable ABI (abi3-py311), so one wheel covers 3.11 and newer: Linux x86_64 and aarch64, macOS x86_64 and arm64, Windows x64.

Published wheels enable common only: text, documents, images, audio and video, archives, executables, certificates, databases, source code, and the rest of the default collection. geo, science, data, cad, forensics, and games are a source build (maturin develop --features full). There is no CLI in this package.

Limitations

  • extract of bytes copies the buffer once. A file object is read up to the read cap. There is no streaming reader.
  • A native file_timeout can leave a Rust worker running after the call returns.
  • IO error messages include the full path.

https://github.com/SinAnima/whiff-python · https://pypi.org/project/whiff-python/ · upstream https://github.com/SinAnima/whiff