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.1.tar.gz (20.1 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.1-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.1-cp313-cp313-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

exhash-0.1.1-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.1-cp312-cp312-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

exhash-0.1.1-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.1-cp311-cp311-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

exhash-0.1.1-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.1-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.1.tar.gz.

File metadata

  • Download URL: exhash-0.1.1.tar.gz
  • Upload date:
  • Size: 20.1 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.1.tar.gz
Algorithm Hash digest
SHA256 b3bdfba6cd7349ec47a87b942df4524c2665d8f4463e7e8c08a675ad9bfb06fe
MD5 71c06355607c75ae484230bd36584be7
BLAKE2b-256 e3daf680ee13894e7a669570837088c997515f7176501554c0cb825cbb097d85

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.1.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.1-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for exhash-0.1.1-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 76c08bfc8dfbdec56a0962258ebacee3d55e9e067e19de2d1de2fb01de971288
MD5 a6b3dd59ab3d3d70ac8fd611bafb05af
BLAKE2b-256 455cd895ee94f770f9d5544c31b776fa7b4403c7ad0591f94cb32a2261f5ee91

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.1-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.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for exhash-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fa714b6108424792d7c1ba8594410a22f0ab285c5d1a6927a30efb449a833391
MD5 992d54f1ac232ce392450f27c2af583b
BLAKE2b-256 8f6dc5c8dec9e1677692ba14b9f5dcf7997d6731102f55514832329e8c28ed3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.1-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.1-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for exhash-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1d7f63d7d7b504844a3eb2d89036b62edd02e9fe1b097ec53a1cd7ac4f361e65
MD5 5b56d52c05bf375c24e4fcc655cd1c77
BLAKE2b-256 9496968ccfb6f83276649c37bf16c54f1dd640d975ddf209e0bb8ea053cf70f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.1-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.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for exhash-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b4fde4f49facc7eb3d88d5fe2d740e25548bcc01be34d3974615e79948384d60
MD5 9cd4cdc446d8a52b0d3327d52678a491
BLAKE2b-256 45bbf089c0fb68b38ce41d62b8c8c6f59eecc0df310e685591d3dd5d94bea3dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.1-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.1-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for exhash-0.1.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 500a582f63fb633fa5d73b9c7d79771c419f5f281001aaedb1c9848fc1fc66e0
MD5 0baf58c126949800931aed4a599dd2a7
BLAKE2b-256 de750e072b59c88b7275b46768461a65ad6f381ae269e9424a3deb1ca986db9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.1-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.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for exhash-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 faedbc5dfe4da8a4bad3150a38167bb0044454f61f41b9a54670249d4f6f7985
MD5 59af17fed6611402908e0478b0f4e616
BLAKE2b-256 13712e1afa8e1cd28d9d60daf481ff30f52b1019282e684bd63e5ad621ff21d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.1-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.1-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for exhash-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7a8e7da3523df2910bf526dcea731419ee64c126ab1c286289ce96794ed9da53
MD5 51863a390ff25855899a543c86452d12
BLAKE2b-256 420c4cbd5cf379e0b53ce511ca8027cd606a6c62bb37c7df17024faea57c8ad6

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.1-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.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for exhash-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9cbbb9cd3c234bbd42e02d6209a6b5ca397869b4cfe43cada5c376525a5ae82c
MD5 902029bfb9e22a9eb75f501e53a4f99f
BLAKE2b-256 3d700783675268a781d044b39f36efff55ec542e6cd3f1aa406361ad9be6e739

See more details on using hashes here.

Provenance

The following attestation bundles were made for exhash-0.1.1-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