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.2

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.2
File Size Uploaded
textprov-0.1.2.tar.gz 16.0 kB Details

Built distribution (wheel)

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

Total release size: 28.3 kB

Release files / textprov-0.1.2.tar.gz

Download URL textprov-0.1.2.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5957c6f21d5864b281902f41f16dfca8f4d7a9856e151e8361c679d7be9aeea2
BLAKE2b-256 checksum
How to use checksums
aa339937d167faac59465514cb6e02b396018e25ff62a4bac457e3e8b090519f
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.2-py3-none-any.whl

Download URL textprov-0.1.2-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6035df54efe481b383e561e38e53ec5131a4b5af50614c17f1ae7f17b95c6f69
BLAKE2b-256 checksum
How to use checksums
bedffbd6fa736ebaff6eb7ef57472027a55bbc20c0505a39de10bc746e325cd0
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

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

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