A syntactic patching library with char-level granularity
Project description
textum-py
Python bindings for textum - a syntactic patching library with char-level granularity.
Installation
pip install textum
Quick Start
import textum
# Create a simple patch
patch = textum.Patch.from_literal_target(
file="example.txt",
needle="old text",
mode="include",
replacement="new text"
)
# Apply to string content
content = "This is old text in a file"
result = patch.apply_to_string(content)
print(result) # "This is new text in a file"
# Work with multiple patches
patchset = textum.PatchSet()
patchset.add(patch)
# Apply to actual files
results = patchset.apply_to_files()
Advanced Usage
Using Snippets and Boundaries
# Create a target
target = textum.Target.literal("hello")
# Create a boundary with mode
boundary = textum.Boundary(target, "include")
# Create a snippet
snippet = textum.Snippet.at(boundary)
# Create a patch with the snippet
patch = textum.Patch(
file="test.txt",
snippet=snippet,
replacement="goodbye"
)
Line-based Patching
# Delete lines 5-10
patch = textum.Patch.from_line_range(
file="large_file.txt",
start_line=5,
end_line=10,
replacement=""
)
Between Markers
# Replace content between HTML comments
start = textum.Boundary(
textum.Target.literal("<!-- start -->"),
"exclude"
)
end = textum.Boundary(
textum.Target.literal("<!-- end -->"),
"exclude"
)
snippet = textum.Snippet.between(start, end)
patch = textum.Patch(
file="template.html",
snippet=snippet,
replacement="new content"
)
JSON Import/Export
# Load patches from JSON
json_data = '[{"file": "test.txt", ...}]'
patches = textum.load_patches_from_json(json_data)
# Save patches to JSON
json_str = textum.save_patches_to_json(patches)
License
MIT
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
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 textum-0.1.0.tar.gz.
File metadata
- Download URL: textum-0.1.0.tar.gz
- Upload date:
- Size: 87.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afeeff7e96433451499c27d71434b250028687c6e1d2101b0a9243870f39265a
|
|
| MD5 |
d962a89c463e9510ccdd5f068faa9e74
|
|
| BLAKE2b-256 |
a4ca2a98d98d65b9f174b0dc2abe93e60dfe36c05c2642304a1ffd6ad260edd6
|
File details
Details for the file textum-0.1.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: textum-0.1.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 963.8 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
964ccb63e63f06a413b7ca718748aabddd8f0855d3d8a90e8e47262fdcfda25e
|
|
| MD5 |
abaf8fc3e011854bb8d3110c6bf3d1d1
|
|
| BLAKE2b-256 |
f8aada39b67556bde1b43a8c0f292e80074dce57283061970af9fca9af8da334
|
File details
Details for the file textum-0.1.0-cp39-abi3-win32.whl.
File metadata
- Download URL: textum-0.1.0-cp39-abi3-win32.whl
- Upload date:
- Size: 905.3 kB
- Tags: CPython 3.9+, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1672e1c21da6ca32aa1b5fb1c26d4c5f5ea7a9d3bcd0282215e3f040898e716
|
|
| MD5 |
e6e1305b2ff4b6829485c18a674d9fed
|
|
| BLAKE2b-256 |
21fa8c95cda76843afb1ea00f24bc7f0673aebc00cf667d682ecdb525463656a
|
File details
Details for the file textum-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: textum-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6404412ac59e5171b722a053e73769715c67a5621578e564eaaafae52ab46a3e
|
|
| MD5 |
a7309a008d680ca7bd6f8a46ed9b02b3
|
|
| BLAKE2b-256 |
f660da8f8d194bedafe2d75b89d08283720487141d29caeea28b4972a4a77ae8
|
File details
Details for the file textum-0.1.0-cp39-abi3-musllinux_1_2_i686.whl.
File metadata
- Download URL: textum-0.1.0-cp39-abi3-musllinux_1_2_i686.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6fcb98775a7c2f92e542abaa6753b43451e84e33438febe5cca2938a448b32c
|
|
| MD5 |
34138d1c34153699419d2f037a4f1860
|
|
| BLAKE2b-256 |
18e7a7b38cb6c5e02736e3640c20f3459b4547ac3727a06b124fdb8b175f92a9
|
File details
Details for the file textum-0.1.0-cp39-abi3-musllinux_1_2_armv7l.whl.
File metadata
- Download URL: textum-0.1.0-cp39-abi3-musllinux_1_2_armv7l.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f22b639b438a83e7666dad27de5f0ddc42b8ba99c5a7d4996f885d34880efcd6
|
|
| MD5 |
7801a92450d1184108eb13bc882b2a1c
|
|
| BLAKE2b-256 |
c23a7efed5c6bbfe444320f4f80b5f69c582492ce3ecc75b5c74b7032d046b20
|
File details
Details for the file textum-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: textum-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07674f8bc6119e67008d9bc0f9e10c0b04893d83a34d4ca8872fc5beb3c42f3d
|
|
| MD5 |
fb41b41fc4ef8ccf6b7a165df239e95a
|
|
| BLAKE2b-256 |
bc4d483b5c6b558973f6fcd606c28d869c2dd10a7d73398676e70e5598b69927
|
File details
Details for the file textum-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: textum-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cf42f95eca45af5d43a2ba306cd1e3c81ad68a8a5d4873d9eff5aaa6fecc1b7
|
|
| MD5 |
adcc729b9a7cf8eb1d22a8be7e27f622
|
|
| BLAKE2b-256 |
5c07e897e58afa96ded75f4a6de56e7e3f98af1d8e3d296f2cb277c4398560da
|
File details
Details for the file textum-0.1.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: textum-0.1.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
665bf9c6a45d58779eddabfd2630c0272ab30a995cf5dc1ae77baea232d53b33
|
|
| MD5 |
78ed5bfc80857df3f0ec4eb62d346018
|
|
| BLAKE2b-256 |
6e51f1014e955c0cef673af04ac40759207cb2915c3ba3f36273b0a0a2eda95d
|
File details
Details for the file textum-0.1.0-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: textum-0.1.0-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3915dff78af334d433c92aaa5aaf364b68c3e145594a574762ea9987e11d025
|
|
| MD5 |
cef4ac9da554bbd95be922dca36701f8
|
|
| BLAKE2b-256 |
c2dfefaaf194c0a275593ca1a826d4f3adf82f53741f19f1068e010bdd5e2c82
|
File details
Details for the file textum-0.1.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: textum-0.1.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 990.1 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48ec78aaba9af9c81b44a2766b0de43342a97a9f4e34a098de0e78be2257b920
|
|
| MD5 |
288e480bfe3373249c5b44c982b81172
|
|
| BLAKE2b-256 |
872987ba71a4fefcfb25c7cfd854cde56ddff0d2f82bb951b22db6b41f265687
|
File details
Details for the file textum-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: textum-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 996.6 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bec026d84a0f11e9f601e83b6c25088f90e467e56381fd1adb9f1513a4489cc
|
|
| MD5 |
f520f368e9c0a43297cac249f3021e3e
|
|
| BLAKE2b-256 |
ff843298d72e83ce220c47a14426144d824d41bd9422296d830b82034f3c700f
|
File details
Details for the file textum-0.1.0-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl.
File metadata
- Download URL: textum-0.1.0-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9+, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13b656c8c0d4103329f10e05caa47795e5bdfc85eb3b70718de3992fad71fc72
|
|
| MD5 |
d2cfef520ec00e24872604aac8136596
|
|
| BLAKE2b-256 |
9ca6a59f85acc4a53fa6f05812b27873c51194fdebc01b0f0de778bd87a0cae2
|
File details
Details for the file textum-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: textum-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 944.0 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0450799c800db35da6bca573edd65c7ecd7e0fbd22a3adc5b1f9d5b13c4f3147
|
|
| MD5 |
6621e06868612b5d7530892c94ae4e02
|
|
| BLAKE2b-256 |
dacec65031f85d92051139d87bd0a4764b0cfb58ec9977f7d4855ea7b67838eb
|
File details
Details for the file textum-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: textum-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.13.3 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f7a25f5bc5c8733bc5c0c07bda2bbd208ba50e1aa8e1244ca91a0f74a8aa655
|
|
| MD5 |
f8d87c08a37707b0b9cbbbb83b294361
|
|
| BLAKE2b-256 |
6cb2456311eb25f28f1352498525430034898a8d3e572fc524af9474be727d20
|