Verified line-addressed file editor using lnhash addresses
Project description
exhash — Verified Line-Addressed File Editor
exhash combines Can Bölük's very clever line number + hash editing system with the powerful and expressive syntax of the classic ex editor.
Install via pip to get both a convenient Python API, and native CLI binaries:
pip install exhash
Or install just the CLI binaries via cargo:
cargo install exhash
lnhash format
We refer to an lnhash as a tag of the form lineno|hash|, where hash is the lower 16 bits of Rust's DefaultHasher over the line content. exhash is just like ex, except that addresses must be in lnhash format. Addresses like %, ., etc are not permitted.
CLI
The native Rust binaries are installed into your PATH via pip.
View
# Shows every line prefixed with its lnhash
lnhashview path/to/file.txt
# Optional line number range to show
lnhashview path/to/file.txt 10 20
Edit
# Substitute on one line
exhash file.txt '12|abcd|s/foo/bar/g'
# Append multiline text (terminated by a single dot)
exhash file.txt '12|abcd|a' <<'EOF'
new line 1
new line 2
.
EOF
# Dry-run
exhash --dry-run file.txt '12|abcd|d'
For a/i/c commands, provide the text block on stdin:
printf "new line 1\nnew line 2\n.\n" | exhash file.txt "2|beef|a"
Stdin filter mode
cat file.txt | exhash --stdin - '1|abcd|s/foo/bar/'
In --stdin mode, multiline a/i/c text blocks are not available.
Python API
from exhash import exhash, exhash_result, lnhash, lnhashview, line_hash
Viewing
text = "foo\nbar\n"
view = lnhashview(text) # ["1|a1b2| foo", "2|c3d4| bar"]
Editing
exhash(text, cmds) takes the text and a required list of command strings (use [] for no-op). For a/i/c commands, lines after the command are the text block (no . terminator needed):
addr = lnhash(1, "foo") # "1|a1b2|"
res = exhash(text, [f"{addr}s/foo/baz/"])
print(res["lines"]) # ["baz", "bar"]
print(res["modified"]) # [1]
# Multiple commands
a1, a2 = lnhash(1, "foo"), lnhash(2, "bar")
res = exhash(text, [f"{a1}s/foo/FOO/", f"{a2}s/bar/BAR/"])
# Append multiline text (no dot terminator)
res = exhash(text, [f"{addr}a\nnew line 1\nnew line 2"])
Result dict
lines— list of output lineshashes— lnhash for each output linemodified— 1-based line numbers of modified/added linesdeleted— 1-based line numbers of removed lines (in original)
exhash_result([res1, res2, ...]) renders modified lines in lnhash format, matching the old repr(EditResult) style.
Tests
cargo test && pytest -q
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file exhash-0.1.4.tar.gz.
File metadata
- Download URL: exhash-0.1.4.tar.gz
- Upload date:
- Size: 22.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb8aa00e2be39431454e077c05da3c82292a6e63e72332eecc60666ab8438a48
|
|
| MD5 |
b00b88cce67c81d15bf48ea5e20cb4b7
|
|
| BLAKE2b-256 |
6c1b6d0a5ac5f08af48afcdfbb5364e3896e59b08cffdb1d94e057760f99797e
|
Provenance
The following attestation bundles were made for exhash-0.1.4.tar.gz:
Publisher:
ci.yml on AnswerDotAI/exhash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exhash-0.1.4.tar.gz -
Subject digest:
eb8aa00e2be39431454e077c05da3c82292a6e63e72332eecc60666ab8438a48 - Sigstore transparency entry: 996047994
- Sigstore integration time:
-
Permalink:
AnswerDotAI/exhash@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/AnswerDotAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Trigger Event:
push
-
Statement type:
File details
Details for the file exhash-0.1.4-cp313-cp313-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: exhash-0.1.4-cp313-cp313-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52ef2419c35d36877722412891de66ee51fdd29f7f6a15b9884c83e3f2a0b747
|
|
| MD5 |
f240acc7744718fdc3f7d74fecee19b7
|
|
| BLAKE2b-256 |
f6db818da56eebb753dc2a025a61e48d41c1ebf8dc81a4d27606178412f11786
|
Provenance
The following attestation bundles were made for exhash-0.1.4-cp313-cp313-manylinux_2_34_x86_64.whl:
Publisher:
ci.yml on AnswerDotAI/exhash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exhash-0.1.4-cp313-cp313-manylinux_2_34_x86_64.whl -
Subject digest:
52ef2419c35d36877722412891de66ee51fdd29f7f6a15b9884c83e3f2a0b747 - Sigstore transparency entry: 996048393
- Sigstore integration time:
-
Permalink:
AnswerDotAI/exhash@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/AnswerDotAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Trigger Event:
push
-
Statement type:
File details
Details for the file exhash-0.1.4-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: exhash-0.1.4-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5a5604654613ebddbaed23ebe01bfa1a65977751ecceb2a166b6b0ce5ad5f26
|
|
| MD5 |
e645cfe251917bdddc040178d9bcae95
|
|
| BLAKE2b-256 |
04c47a3a14e50253cd7d5e1c6789d1b74b5f4f47da924f75404ff8c651b3605e
|
Provenance
The following attestation bundles were made for exhash-0.1.4-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
ci.yml on AnswerDotAI/exhash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exhash-0.1.4-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
d5a5604654613ebddbaed23ebe01bfa1a65977751ecceb2a166b6b0ce5ad5f26 - Sigstore transparency entry: 996048251
- Sigstore integration time:
-
Permalink:
AnswerDotAI/exhash@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/AnswerDotAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Trigger Event:
push
-
Statement type:
File details
Details for the file exhash-0.1.4-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: exhash-0.1.4-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
116c0162e5bc6fba788ad2db4709f2fb0b6f69f1ce22ad839605d5062d29eeb6
|
|
| MD5 |
4e83c0e0894a2752891fd5f66823e0cb
|
|
| BLAKE2b-256 |
cb7f9f3f0684a174b4fe62cae561454b789d40a8fa6c9d6c1a3716992ea285e0
|
Provenance
The following attestation bundles were made for exhash-0.1.4-cp312-cp312-manylinux_2_34_x86_64.whl:
Publisher:
ci.yml on AnswerDotAI/exhash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exhash-0.1.4-cp312-cp312-manylinux_2_34_x86_64.whl -
Subject digest:
116c0162e5bc6fba788ad2db4709f2fb0b6f69f1ce22ad839605d5062d29eeb6 - Sigstore transparency entry: 996048048
- Sigstore integration time:
-
Permalink:
AnswerDotAI/exhash@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/AnswerDotAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Trigger Event:
push
-
Statement type:
File details
Details for the file exhash-0.1.4-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: exhash-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cbcd36cb635eb521d933bfe07e97ec457d96dbe8e8623922fcacabbfc32062d
|
|
| MD5 |
a5fb098b498470f14bc3f499d5158151
|
|
| BLAKE2b-256 |
635d244af8bd319b621aeb902bf858917e94d99bb647cb10384f3dca0f304f73
|
Provenance
The following attestation bundles were made for exhash-0.1.4-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
ci.yml on AnswerDotAI/exhash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exhash-0.1.4-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
2cbcd36cb635eb521d933bfe07e97ec457d96dbe8e8623922fcacabbfc32062d - Sigstore transparency entry: 996048174
- Sigstore integration time:
-
Permalink:
AnswerDotAI/exhash@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/AnswerDotAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Trigger Event:
push
-
Statement type:
File details
Details for the file exhash-0.1.4-cp311-cp311-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: exhash-0.1.4-cp311-cp311-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
318e7deadccc448adaec18c99bebeb64fd8de747f4b768d5d9b9671326c08d90
|
|
| MD5 |
6d5bfa75ea5847ed0ca3e493b1c48e00
|
|
| BLAKE2b-256 |
1f6d114b6fc9f289ae6132f4154525b7b8e3725cd3ce1625cd3b5cab860fa13e
|
Provenance
The following attestation bundles were made for exhash-0.1.4-cp311-cp311-manylinux_2_34_x86_64.whl:
Publisher:
ci.yml on AnswerDotAI/exhash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exhash-0.1.4-cp311-cp311-manylinux_2_34_x86_64.whl -
Subject digest:
318e7deadccc448adaec18c99bebeb64fd8de747f4b768d5d9b9671326c08d90 - Sigstore transparency entry: 996048481
- Sigstore integration time:
-
Permalink:
AnswerDotAI/exhash@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/AnswerDotAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Trigger Event:
push
-
Statement type:
File details
Details for the file exhash-0.1.4-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: exhash-0.1.4-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
251908680abd6718b8313dbfb963a35edd8b9dbce925804b4ef627c2ed425941
|
|
| MD5 |
4a392514e97244106ce620972149a944
|
|
| BLAKE2b-256 |
d70f3272f980164022268ef96ba395d090b973cbbd5a65f8edf47fab3992b679
|
Provenance
The following attestation bundles were made for exhash-0.1.4-cp311-cp311-macosx_11_0_arm64.whl:
Publisher:
ci.yml on AnswerDotAI/exhash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exhash-0.1.4-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
251908680abd6718b8313dbfb963a35edd8b9dbce925804b4ef627c2ed425941 - Sigstore transparency entry: 996048333
- Sigstore integration time:
-
Permalink:
AnswerDotAI/exhash@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/AnswerDotAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Trigger Event:
push
-
Statement type:
File details
Details for the file exhash-0.1.4-cp310-cp310-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: exhash-0.1.4-cp310-cp310-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.10, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a6ef80a32ffda3c17f0527f57d26570b4e919e6576906c13ce5d9b6ef992d38
|
|
| MD5 |
4a71c4731472de04a6d655d0f505640e
|
|
| BLAKE2b-256 |
7b9b3f35ca81c93d0cf1ca3652c184172a0571df7a314164ea091aadef4dbed8
|
Provenance
The following attestation bundles were made for exhash-0.1.4-cp310-cp310-manylinux_2_34_x86_64.whl:
Publisher:
ci.yml on AnswerDotAI/exhash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exhash-0.1.4-cp310-cp310-manylinux_2_34_x86_64.whl -
Subject digest:
8a6ef80a32ffda3c17f0527f57d26570b4e919e6576906c13ce5d9b6ef992d38 - Sigstore transparency entry: 996048536
- Sigstore integration time:
-
Permalink:
AnswerDotAI/exhash@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/AnswerDotAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Trigger Event:
push
-
Statement type:
File details
Details for the file exhash-0.1.4-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: exhash-0.1.4-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa6734865891955795d1805fff2d1334810068349a5f20b30502cced263f583d
|
|
| MD5 |
7a9001ef890e8b0f5466aa5d6be26e37
|
|
| BLAKE2b-256 |
9e0468305e87b37ab8bf2836908f4a9efadafdf832784d2051034aa7a4a700f0
|
Provenance
The following attestation bundles were made for exhash-0.1.4-cp310-cp310-macosx_11_0_arm64.whl:
Publisher:
ci.yml on AnswerDotAI/exhash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exhash-0.1.4-cp310-cp310-macosx_11_0_arm64.whl -
Subject digest:
aa6734865891955795d1805fff2d1334810068349a5f20b30502cced263f583d - Sigstore transparency entry: 996048120
- Sigstore integration time:
-
Permalink:
AnswerDotAI/exhash@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/AnswerDotAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@48a78f1ebbfeed26340231ab5f2ebd626231ed3f -
Trigger Event:
push
-
Statement type: