$ show deanmalmgren/textract
Textract is a text extraction library and command-line tool that extracts text from over 30 file formats including PDF, DOC, DOCX, images, audio, email, and structured data formats. The architecture centers around a parser registry that routes files to format-specific parsers based on extension, with a unified Source abstraction handling file paths, bytes, and streams as input. Key entry points are the Python API (textract.process()) and CLI interface (textract.bin.textract). The system relies on external tools like Poppler, Tesseract, and LibreOffice for certain formats while using pure Python parsers for others. The codebase demonstrates strong engineering practices with a clean plugin architecture, comprehensive test suite, and modern tooling (uv, ruff, pytest).
The LLM identified 2 files worth highlighting for reuse:
Defines the Source class (unifying file, bytes, and stream input) and base parser classes (Parser, DecodedParser, BytesParser, ShellParser). This abstraction allows parsers to handle different input types uniformly without duplicating code, making it highly reusable in any project needing flexible input handling for parsing tasks.
Implements a parser registry and extension resolution mechanism (handling synonyms like .jpeg→.jpg) that dynamically loads parser modules based on file extension. This plugin architecture pattern is reusable for any system needing to route files to appropriate handlers based on metadata or extension.