--- id: polyfile-weave version: "0.5.9" license: unclear license_treatment: permissive maintenance: aging --- # polyfile-weave — A utility to recursively map the structure of a file. License: permissive · Maintenance: aging · Downloads: 935.5K/mo ## What it is and what it does PolyFile is a file analysis utility that identifies file types and recursively maps their internal structure, including detecting polyglots (files with multiple valid formats), chimeras, and embedded files. It includes a cleanroom pure-Python implementation of libmagic that supports 263 MIME types and can act as a drop-in replacement for the Unix `file` command, but with the added capability to recursively identify files embedded within other files—similar to binwalk. The package supports parsing and semantic mapping of PDF, ZIP, JPEG/JFIF, iNES, and any format specified in a Kaitai Struct grammar. It offers multiple output formats (including an extension of the SBuD JSON format), an interactive debugger for troubleshooting file matching and parsing, and both command-line and programmatic interfaces. The package automatically patches a known issue with Kaitai Struct's auto-generated Python code on import. Use it for: - Analyze polyglot files to understand all embedded file types and their byte offsets within a single file. - Recursively extract and identify all files embedded within ZIP archives or PDF documents programmatically. - Generate interactive HTML hex viewers of files with semantic structure annotations for forensic analysis. - Debug why a file is not being classified with the expected MIME type using the built-in interactive debugger. - Replace the system `file` command in scripts while gaining recursive file identification capabilities. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Identifies and maps the semantic and syntactic structure of files, including polyglots and embedded files, with a pure-Python libmagic implementation that can replace the `file` command and recursively extract embedded content. Yes, if you need recursive file identification and polyglot detection. The pure-Python libmagic implementation and low install friction make it accessible, and Apache 2.0 licensing poses no restrictions. However, the aging maintenance status (204 days since last release, minimal repository activity) and 14 runtime dependencies warrant caution for production use—verify that the package remains stable for your specific file formats and that dependency bloat is acceptable for your use case. ## Install pip install polyfile-weave uv add polyfile-weave poetry add polyfile-weave ## Installing polyfile-weave Before you install: Low install friction with a pure-Python wheel. Maintenance status is aging—last release was 204 days ago and the repository has minimal activity (2 stars), though it remains unarchived and the codebase was last updated on 2026-01-22. License in practice: Licensed under Apache 2.0 (permissive), which allows commercial and private use with minimal restrictions, making it safe to adopt in most projects. Quickstart: pip install polyfile-weave from polyfile.magic import MagicMatcher with open("file_to_test", "rb") as f: for match in MagicMatcher.DEFAULT_INSTANCE.match(f.read()): for mimetype in match.mimetypes: print(f"Matched MIME: {mimetype}") Java must be installed before installing from source, as it is required to run the Kaitai Struct compiler for file format definitions. Verify before relying: - Whether the 14 runtime dependencies (including graphviz, Pillow, pdfminer.six) are all truly required for basic file identification or only for specific features. - Current stability and bug-fix rate given the aging maintenance status and minimal repository activity. - Whether the automatic patching of the Kaitai Struct Python reserved keyword issue works reliably across all installation scenarios. ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 935.5K/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags file type identification, polyglot file detection, embedded file extraction, file format analysis, recursive file parsing, libmagic python implementation, file structure mapping, file-analysis, polyglot-detection, forensics [View on SkillFed](https://skillfed.io/packages/polyfile-weave) · [View on PyPI](https://pypi.org/project/polyfile-weave/)