Skip to main content

Verified line-addressed file editor using lnhash addresses

Project description

exhash — Verified Line-Addressed File Editor

This repository contains:

  • crates/exhash-core: the Rust library
  • src/bin/: two native CLIs (exhash, lnhashview)
  • python/exhash: PyO3 bindings exposing the string-based engine

Install via pip to get both the Python API and native CLI binaries:

pip install exhash

Or install just the CLI binaries via cargo:

cargo install exhash

lnhash format

lineno|hash| where hash is the lower 16 bits of Rust's DefaultHasher over the line content.

CLI

The native Rust binaries are installed into your PATH via pip.

View

lnhashview path/to/file.txt
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, 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 one or more command strings. 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.text())      # "baz\nbar"
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")

EditResult

  • .lines — list of output lines
  • .hashes — lnhash for each output line
  • .modified — 1-based line numbers of modified/added lines
  • .deleted — 1-based line numbers of removed lines (in original)
  • .text() — joined output
  • .view() — output in lnhash format
  • repr() — shows only modified lines in lnhash format

Tests

cargo test && pytest -q

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

exhash-0.1.2.tar.gz (21.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

exhash-0.1.2-cp313-cp313-manylinux_2_34_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

exhash-0.1.2-cp313-cp313-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

exhash-0.1.2-cp312-cp312-manylinux_2_34_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

exhash-0.1.2-cp312-cp312-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

exhash-0.1.2-cp311-cp311-manylinux_2_34_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

exhash-0.1.2-cp311-cp311-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

exhash-0.1.2-cp310-cp310-manylinux_2_34_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

exhash-0.1.2-cp310-cp310-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file exhash-0.1.2.tar.gz.

File metadata

  • Download URL: exhash-0.1.2.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for exhash-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5053b3f930d4537934a3289a63a385f7e87f5a332b954c42871fe4cc6e1dde4a
MD5 2e4558eebb24980198b5d446515d6bff
BLAKE2b-256 7a45c7ebcdb2b98d7c0774c5f38f46b5ecde4b7d0666d11441c2e9b8d2ac2f69

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.2.tar.gz:

Publisher: ci.yml on AnswerDotAI/exhash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exhash-0.1.2-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for exhash-0.1.2-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3d1445eeff670dc449a3d47ecee46ab237ded784bfec1879add55488e33f0129
MD5 f66f44cffbf6724c9fab9e31e8debcb2
BLAKE2b-256 979fa967a2cc7e0554f676d00d9f421df3de3156416ed75f1ab7c2ed17dc8a08

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.2-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: ci.yml on AnswerDotAI/exhash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exhash-0.1.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for exhash-0.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 17bcdb382e465351d3fef81f2f6be72695c33dccd8a3df28c1a8147736df3825
MD5 3a5b3c60ba5881b1c7d797bd3473f256
BLAKE2b-256 8add676fb4e0815de13980a611982ca61b884b7e19437fa94d684fe861bcdfc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.2-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: ci.yml on AnswerDotAI/exhash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exhash-0.1.2-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for exhash-0.1.2-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d2e4754980c42871c252c4eb3616fa7ad3a08cc904cd91ffdd25d3c98b610ea8
MD5 8ae3f1d3b1623fae90c3dfe76c9c3fe0
BLAKE2b-256 fb8bcede17a62154ffe3afae08e043e51707fa70f530af768de59f45020159f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.2-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: ci.yml on AnswerDotAI/exhash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exhash-0.1.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for exhash-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0a0f878096be4c4a6d6e4b89083ff1e3d231f08df47de287ace638a54277b97d
MD5 548fa8c2e87494d04e8c3d92a948e249
BLAKE2b-256 af52abb6cfed066014b31b6d87f3feb83ac36be8dfca4ee684a03508b59aac71

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: ci.yml on AnswerDotAI/exhash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exhash-0.1.2-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for exhash-0.1.2-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 10f6bcb2e7619c33df7af4c388ff87bce28f811e410fa23a21968bdf90d45b3b
MD5 779b836704e6b437fced2220690ec52f
BLAKE2b-256 b2cdc96789568a15bf78e1c837ffb447d4306ae0e942b7d47b4b25ad148bdebe

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.2-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: ci.yml on AnswerDotAI/exhash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exhash-0.1.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for exhash-0.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c062ff571f5e02fc9239c200ebc14189169cd558d9542f335bef15bd0b706b44
MD5 322b9280a4ad1af705b299915d9c35df
BLAKE2b-256 0de1d33e8c82d59348d869188063b38d488bb5649e5dcb1012e51c53a682b53e

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.2-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: ci.yml on AnswerDotAI/exhash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exhash-0.1.2-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for exhash-0.1.2-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 69e4764c27254dee35ea7c1f9368f139cd0a3d57b019a9808aefac5dcfba5f71
MD5 d1375cff9acbee50da90e7155d2d4a9b
BLAKE2b-256 105ce582f8f26b0a97c9863754a8de2f536814390872d0b52357a170b59819c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.2-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: ci.yml on AnswerDotAI/exhash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exhash-0.1.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for exhash-0.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c91d3e106cedf3686624d618870d1c150a7c5f67e58029660fa0f6e34de4cea8
MD5 fb907359be8e5ae88b35a933b15c72e6
BLAKE2b-256 c8c8c7010a61da9fe324c4f3a43fe124e4313f3f3975e03fbf163c0c715c33ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.2-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: ci.yml on AnswerDotAI/exhash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page