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.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| textprov-0.1.3.tar.gz | 16.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| textprov-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.5 kB
Release files / textprov-0.1.3.tar.gz
| Download URL | textprov-0.1.3.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
30a90a19cd944f44453ae43f7a46fdde6e01368aa45b0bcf4ee724020fd15490
|
|
BLAKE2b-256 checksum How to use checksums |
02dd5c20a7b309b50058516f5e0d3c21fe16eca69da82eacc950cc8bb9feaa16
|
| 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.3-py3-none-any.whl
| Download URL | textprov-0.1.3-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8df3d827222a92b271912f7d72cd4d2746566d49a5568db4144c5b0d04f1429
|
|
BLAKE2b-256 checksum How to use checksums |
d84ff74f42efbe3252be043cbc4ac6bc1a3e1df948f9f7cdc4ea5ba97d7b6717
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|