Skip to main content

detextive

Package Version PyPI - Status Tests Status Code Coverage Percentage Project License Python Versions

🕵️ A Python library which provides consolidated text detection capabilities for reliable content analysis. Offers MIME type detection, character set detection, and line separator processing.

Key Features ⭐

🔍 MIME Type Detection

Intelligent content-based detection using magic bytes with file extension fallback for comprehensive format identification.

📝 Character Encoding Detection

Statistical analysis with UTF-8 optimization and validation through decode operations for reliable text processing.

📄 Line Separator Processing

Cross-platform line ending detection and normalization supporting CR, LF, and CRLF formats with mixed-content handling.

✅ Textual Content Validation

Smart classification of MIME types and content reasonableness assessment using control character and printability heuristics.

Installation 📦

Method: Install Python Package

Install via uv pip command:

uv pip install detextive

Or, install via pip:

pip install detextive

Examples 💡

Basic Usage

MIME Type and Charset Detection:

Load your content as bytes:

import detextive

with open( 'document.txt', 'rb' ) as file:
    content = file.read( )

You can detect MIME type and charset individually:

mimetype = detextive.detect_mimetype( content, location = 'document.txt' )
charset = detextive.detect_charset( content )

Or use combined inference for better accuracy:

mimetype, charset = detextive.infer_mimetype_charset(
    content, location = 'document.txt' )
print( "Detected: {mimetype} with {charset} encoding".format(
    mimetype = mimetype, charset = charset ) )

Line Separator Processing:

Detect line separators in mixed content:

import detextive

content = 'Line 1\r\nLine 2\rLine 3\n'
separator = detextive.LineSeparators.detect_bytes( content.encode( ) )

Normalize line separators to Python standard:

normalized = detextive.LineSeparators.normalize_universal( content )

Convert to platform-specific line separators:

native = detextive.LineSeparators.CRLF.nativize( normalized )

Content Classification:

Check if MIME types represent textual content:

import detextive

detextive.is_textual_mimetype( 'application/json' )  # True
detextive.is_textual_mimetype( 'image/jpeg' )        # False

Validate that decoded text content is reasonable:

text = "Hello world!"
detextive.is_valid_text( text )      # True

Binary data that might decode as text but isn’t valid fails validation:

binary_as_text = "Config file\x00\x00\x00data"
detextive.is_valid_text( binary_as_text )  # False

High-Level Decoding:

For complete bytes-to-text processing with automatic charset detection and validation:

import detextive

with open( 'document.txt', 'rb' ) as file:
    content = file.read( )

text = detextive.decode( content, location = 'document.txt' )
print( f"Decoded text: {text}" )

Contribution 🤝

Contribution to this project is welcome! However, it must follow the code of conduct for the project.

Please file bug reports and feature requests in the issue tracker or submit pull requests to improve the source code or documentation.

For development guidance and standards, please see the development guide.

Additional Indicia

GitHub last commit Copier Hatch pre-commit Pyright Ruff PyPI - Implementation PyPI - Wheel

Other Projects by This Author 🌟

  • agentmux (agentmux on Crates.io)

    📡 Provides relays for inter-agent communication and a single pane of glass for managing multiple agent harness sessions.

  • cistella (cistella on Crates.io)

    🧱 A sandboxing application which isolates agent sessions via various technologies.

  • nb-mcp-server (nb-mcp-server on Crates.io)

    🗒️ An MCP server wrapping the nb CLI for LLM-friendly note-taking.

  • python-accretive (accretive on PyPI)

    🌌 A Python library package which provides accretive data structures - collections which can grow but never shrink.

  • python-classcore (classcore on PyPI)

    🏭 A Python library package which provides foundational class factories and decorators for providing classes with attributes immutability and concealment and other custom behaviors.

  • python-dynadoc (dynadoc on PyPI)

    📝 A Python library package which bridges the gap between rich annotations and automatic documentation generation with configurable renderers and support for reusable fragments.

  • python-falsifier (falsifier on PyPI)

    🎭 A very simple Python library package which provides a base class for falsey objects - objects that evaluate to False in boolean contexts.

  • python-frigid (frigid on PyPI)

    🔒 A Python library package which provides immutable data structures - collections which cannot be modified after creation.

  • python-ictr (ictr on PyPI)

    🍦 Non-Intrusive Debugging - A Python library which provides flavored traces, configuration hierarchies, customized outputs, and ready-made recipes for logging and debug printing.

Metadata

Release files for detextive 3.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for detextive 3.2.1
File Size Uploaded Provenance Actions
detextive-3.2.1.tar.gz 23.6 kB With provenance Details for detextive-3.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for detextive 3.2.1
File Interpreter ABI Platform Actions
detextive-3.2.1-py3-none-any.whl Python 3 none any Details for detextive-3.2.1-py3-none-any.whl

Total release size: 55.4 kB

Release files / detextive-3.2.1.tar.gz

Download URL detextive-3.2.1.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6a0efaac92ef5991866fca80eaa82e25ebd706ca831c029d3c969c6a3198b655
BLAKE2b-256 checksum
How to use checksums
8240d4a94beb66cd15ef47b929b72b18ca1c0fca3e0de2f5b4373bccc9046ce1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / detextive-3.2.1-py3-none-any.whl

Download URL detextive-3.2.1-py3-none-any.whl
Size 31.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6df59be5fbd266a1cbf51403877bcc89e109fc33c097788ccc32b2eabd2c3929
BLAKE2b-256 checksum
How to use checksums
c8e68a3d6891e27f81b3024d551d5ecd2cb6d4a2c651c6773eb6fd2e545c7132
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for detextive 3.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for detextive-3.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page