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.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 textprov 0.1.1
File Size Uploaded
textprov-0.1.1.tar.gz 15.9 kB Details

Built distribution (wheel)

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

Total release size: 28.2 kB

Release files / textprov-0.1.1.tar.gz

Download URL textprov-0.1.1.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e51fafb2f3cec55ab39d58940b1bcf54183c068274f1479cf52e4ec136a324e5
BLAKE2b-256 checksum
How to use checksums
7fd79c7d002cb00e802cd4dcd0f98eb94fd590273b65e98539742b3d2025bd17
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.1-py3-none-any.whl

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

This release

0.1.1 This release

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