Skip to main content

python/README.md


textprov (Python)

The TextProv reference implementation: it puts provenance marks in text and reads them back out. Standard library only.

import textprov

textprov.mark("foo", state="ai")       # 'f\U000E0101o\U000E0101o\U000E0101'
textprov.mark_added("abc", "abXc")     # mark only what an edit added
textprov.convert(marked, "vs", "pua")  # same states, other encoding
textprov.strip_marks(marked)           # back to the original text

textprov.runs("f\U000E0101oo")
# [('ai', 'f\U000E0101'), (None, 'oo')]

textprov.to_html("f\U000E0101oo")
# '<span class="prov prov-ai" data-prov="ai">f\U000E0101</span>oo'

textprov.inspect(marked)               # a 'key: value' report of the states

runs and to_html take strip, merge_whitespace, and (for to_html) class_prefix. mark and mark_added take state and mode ("vs" or "pua"). Every function takes mapping=textprov.Mapping.load(path) to use a registry other than the copy vendored in this package.

CLI

python3 -m textprov -o marked.txt mark --ai draft.txt
python3 -m textprov mark-added old.txt new.txt
python3 -m textprov convert --from vs --to pua marked.txt
python3 -m textprov strip marked.txt
python3 -m textprov render marked.txt
python3 -m textprov inspect marked.txt

An installed package also provides a textprov entry point. A file argument may be - for stdin; output goes to stdout unless -o is given. Text is read and written as UTF-8 verbatim, so CRLF survives.

The protocol is SPEC.md; the registry is mapping.json. textprov/mapping.json is a vendored copy and the test suite fails if it drifts from the canonical file.

Tests

python3 -m unittest discover -s tests -t .

The suite runs every decoder, producer, and convert case in fixtures.json, tests the producer properties from SPEC.md directly rather than only through recorded outputs, and unit-tests cluster_end, to_html, strip_marks, and the CLI.

Metadata

Release files for textprov 0.1.0

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

Source distribution (sdist)

Source distribution for textprov 0.1.0
File Size Uploaded
textprov-0.1.0.tar.gz 16.0 kB Details

Built distribution (wheel)

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

Total release size: 28.3 kB

Release files / textprov-0.1.0.tar.gz

Download URL textprov-0.1.0.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
81746f89cf0a03b27f7081ca60abb518bef5bb4686d7c44361ff96cd2666b4fc
BLAKE2b-256 checksum
How to use checksums
7ec17db171e031bc4b6c01f4ec10bcdc1393974d6010504475fdda9936531225
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release files / textprov-0.1.0-py3-none-any.whl

Download URL textprov-0.1.0-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c7a34a76c6a18d7ac66740f2a3d72236741d4538f6984e73e729d7f64536a0d
BLAKE2b-256 checksum
How to use checksums
00d0a4c3d3074128c9bbfc5667866824e3a79b60aee55a79b5ef7ea964759032
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release history Release notifications | RSS feed

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

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