Skip to main content

A syntactic patching library with char-level granularity

Project description

¶ ⠶ textum

PyPI crates.io documentation MIT/Apache-2.0 licensed pre-commit.ci status

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)

Licensing

Textum is MIT licensed, a permissive open source license.

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

textum-0.2.0.tar.gz (88.5 kB view details)

Uploaded Source

Built Distributions

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

textum-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

textum-0.2.0-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl (1.2 MB view details)

Uploaded PyPymanylinux: glibc 2.5+ i686

textum-0.2.0-pp310-pypy310_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.2 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ s390x

textum-0.2.0-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.2 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ ppc64le

textum-0.2.0-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.0 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARMv7l

textum-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

textum-0.2.0-pp39-pypy39_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.2 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ s390x

textum-0.2.0-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.2 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ ppc64le

textum-0.2.0-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.0 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARMv7l

textum-0.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

textum-0.2.0-cp39-abi3-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.9+Windows x86-64

textum-0.2.0-cp39-abi3-win32.whl (937.8 kB view details)

Uploaded CPython 3.9+Windows x86

textum-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

textum-0.2.0-cp39-abi3-musllinux_1_2_i686.whl (1.3 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ i686

textum-0.2.0-cp39-abi3-musllinux_1_2_armv7l.whl (1.3 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARMv7l

textum-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

textum-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

textum-0.2.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ s390x

textum-0.2.0-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ppc64le

textum-0.2.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARMv7l

textum-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

textum-0.2.0-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl (1.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.5+ i686

textum-0.2.0-cp39-abi3-macosx_11_0_arm64.whl (982.8 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

textum-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file textum-0.2.0.tar.gz.

File metadata

  • Download URL: textum-0.2.0.tar.gz
  • Upload date:
  • Size: 88.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for textum-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ad2e03bf5f06183907e66dc41d03455b00cedea302c284c4b12db6c8a17c3e59
MD5 f95f4e2654bd171dbe457eb806803b2d
BLAKE2b-256 c462678ac6a8263238f32baf3ae3ffbd8ab52a295ee04e63859d070e4a66aa48

See more details on using hashes here.

File details

Details for the file textum-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for textum-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d5ee62955d9bf5be73d0d78f0139b6565822473739a216ecd553e71b019135b5
MD5 8b1a0cebb6c0ebe9c472afd685d0f873
BLAKE2b-256 5efac2290c62f6022aa39bdbf89a47c459c3204deab730bac099a599c84411a9

See more details on using hashes here.

File details

Details for the file textum-0.2.0-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for textum-0.2.0-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 54e2c759ec266a9820e4e3d1e3abbafec598532af75705d17fb3e80220e79e09
MD5 0f45d9c1c34a2ecf7d0bbee74e8b8743
BLAKE2b-256 bc2608e04657ceaa706aa7550c30cfed55c5e2bd6305e63d01fc81d1c77c8561

See more details on using hashes here.

File details

Details for the file textum-0.2.0-pp310-pypy310_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for textum-0.2.0-pp310-pypy310_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 b7d1c2cc140606bf97b76a0145f8acea05f4375cf19211a48c7b3123b31167d7
MD5 1f2946eaaa01477334e8ad9a0cd07abc
BLAKE2b-256 3777c654498a529bfd7d0a200002c046e65de6230303f9bf151e0541d215f995

See more details on using hashes here.

File details

Details for the file textum-0.2.0-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for textum-0.2.0-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 f5d6e6d92a873d979887cb3dc31e2880d90a9bc50361f8e534efad2c20dec6c2
MD5 3fb09cea0a3d96f657fd312f77367843
BLAKE2b-256 faf0b10ee42bd635a19bdec601a31325c7de50f6d7feca4ba2c34e0a19821b5f

See more details on using hashes here.

File details

Details for the file textum-0.2.0-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for textum-0.2.0-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 47b6fa29ca5ec70b467db867957084b9a2502b4c2a75a2a16bfa59897ad75bfc
MD5 f7b2bb400677f63e5b98096a9b976de1
BLAKE2b-256 35444c4ebf8656f9193b1ac4358eac44a1ff6d28365112353dd027e71919a9e5

See more details on using hashes here.

File details

Details for the file textum-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for textum-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7449ff2527a7198bca58bfd66a2e5447abb08a67618b236bff4d899ffdfa8258
MD5 3124a37f3597848c5f9d3d787af4e561
BLAKE2b-256 669c4786becb00444f817d7ca233e15fdb506d96ab5bdc0bc53181b1281c5062

See more details on using hashes here.

File details

Details for the file textum-0.2.0-pp39-pypy39_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for textum-0.2.0-pp39-pypy39_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 045b968038b969798c0a93cf60484be0869b1ca6c22bc21d6068e5f57e6da158
MD5 49cb5575385565e001726e6cae387dae
BLAKE2b-256 89c5bf9696df7840ae821e87ffd0537c1c17eb8fa6c4c30664feddc32c52ac82

See more details on using hashes here.

File details

Details for the file textum-0.2.0-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for textum-0.2.0-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 129bab4380c3dfa9c7ecf9f01f82eedbf0a8c9f4b7eee4a42ce3448c4e8d19a4
MD5 e01d234db7bf8bba480eed1327dc3844
BLAKE2b-256 7509d98831daed14565064ff36a6b041e903180a8f94ab1d7eec63861bd378df

See more details on using hashes here.

File details

Details for the file textum-0.2.0-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for textum-0.2.0-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 98ae70343810e87334b6ab959d8cf7cf880692088819bbeddf741f9876cc96f8
MD5 42b107e350b4fcba9a89563c95fb1e3b
BLAKE2b-256 560e23ffc816aa5da7adef2d8b1374d02c44d04c7fa25bfbfc6092ebf4496960

See more details on using hashes here.

File details

Details for the file textum-0.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for textum-0.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 76907bd102cb942f1220dc660289df5e45a62e5e6166cc19d90548c8a56d90ed
MD5 d32b737d078290179801d72d2cc1be39
BLAKE2b-256 903fcba9d1a870c2c7ec7890a7c92a7db3075496574efddb79f1ca9e8c862d5d

See more details on using hashes here.

File details

Details for the file textum-0.2.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: textum-0.2.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for textum-0.2.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 98d610df6d87dc5d23c04a8254288e7c111b8128aa6c254d90ef62c355de9c04
MD5 672579f89e5ec4eb971f4e913f860ab4
BLAKE2b-256 63ef8d11d3d4cc7eef3a76e397700a9f44690aeda6a9650eeedc65d4417b01a7

See more details on using hashes here.

File details

Details for the file textum-0.2.0-cp39-abi3-win32.whl.

File metadata

  • Download URL: textum-0.2.0-cp39-abi3-win32.whl
  • Upload date:
  • Size: 937.8 kB
  • Tags: CPython 3.9+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for textum-0.2.0-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 b9f8a1e3e8a6feabce81c279d7b25c4f7630f47ca0cbd51dd2b3230bf457d510
MD5 6cc95a5ed139f171efc52b231976b37d
BLAKE2b-256 4407216def9dc499e3e1e7ccee8f5ad4943bbe37131e9c710885d34284faf8be

See more details on using hashes here.

File details

Details for the file textum-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for textum-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f799fba2be41716cb6ea3378cf9ae277db6c5043a863449516c4973e4cf6a067
MD5 8d8a1648595389c0701d49d98e9fe92e
BLAKE2b-256 938ba6d4fc46d5c03f29ee7f5c797895094b9e5273e5e4ef78327bd524510185

See more details on using hashes here.

File details

Details for the file textum-0.2.0-cp39-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for textum-0.2.0-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 ff391fbb0a7c1ff57c2b5859e50ed161d81ee41a0d2e5ad78681971d549c83af
MD5 218784038a88995bfcceb0ce9c5b9ad3
BLAKE2b-256 698cbd6a6f736ef892200a29c25be9a5dfa5097d719cdb01654a29c70cdaba4f

See more details on using hashes here.

File details

Details for the file textum-0.2.0-cp39-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for textum-0.2.0-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 e599f8e1ea4e6aa2ac409f6c363f0a67568a1dede43511627fc6452dc15b4bfa
MD5 6fce76d46b0adf7defbd20361436dc74
BLAKE2b-256 8a0cf74bc0c9da3273993bf2d41de317393be095a2450c3593bd456e288dda09

See more details on using hashes here.

File details

Details for the file textum-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for textum-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 6d119d79b99b1a701d5cb39f6a57d450ffc0d2b35832df5ef1b2525b4475531d
MD5 9587858477f06f95aba143421289963c
BLAKE2b-256 cdde1a8b7e7718228c7fd48207840ffda7993d4daca52cc395f5087715627e39

See more details on using hashes here.

File details

Details for the file textum-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for textum-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ffd1af0eaa0c6479b58d0acf86ff31d598118a06e918da62c20293a9c34e5555
MD5 6f0b8709d3bcb18fe498c477d38a7a16
BLAKE2b-256 0fee8d89fbfe468a5c832eed3a57788341bc6a551b3589e85e726e5ac83ab311

See more details on using hashes here.

File details

Details for the file textum-0.2.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for textum-0.2.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 f1fe0975291a2879e831d0b0cde956d8b66368e27a1957ddf193397555364d50
MD5 135b92a800d3be820fbe97577c4f2f4a
BLAKE2b-256 27e9c870a23d8d709ee2e75ceca5fe131f7a34567b09fa0a4158bb360420aaee

See more details on using hashes here.

File details

Details for the file textum-0.2.0-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for textum-0.2.0-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 814b12a9bbe9b3d8608ea7659741f647350463ddbaf42627e25c3283f8c44fe5
MD5 15cd49ec790815ea1c24a8da308af7e4
BLAKE2b-256 a0c66d0b6a7041128e4c06875ea65c8d50eba8e87fa754f39c2b841695f9076f

See more details on using hashes here.

File details

Details for the file textum-0.2.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for textum-0.2.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 2618b974c63dd6dd834d9cd490270a8561a2fb6bfccf1de3ffe61e8eee14d3f8
MD5 ddb8d99c5f8af1eb381d15099a0bd2f2
BLAKE2b-256 694c2b15115ed89c681fe23361e930f735ce4e119aad158032010c4039d18638

See more details on using hashes here.

File details

Details for the file textum-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for textum-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4bf1aa3f6ed502e00d620666fa9b7e3186c9b13ac851579a1c440a8117b764a0
MD5 f78c4d9d931e3f86d4c74ce23777510b
BLAKE2b-256 86841ac0ceb93194c9399a7429cf11527377f59960a488dd8bc71f070490c90b

See more details on using hashes here.

File details

Details for the file textum-0.2.0-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for textum-0.2.0-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 7bb12ddb3eccf97706b9e4d5ded0f7d74688b92311653473a533149dd9996632
MD5 09aad90ef5a6106a4a5a3c650a6799bb
BLAKE2b-256 50fab4a48f400486613eea5abdba887f2922d261426a3c3535a9d760248e7468

See more details on using hashes here.

File details

Details for the file textum-0.2.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for textum-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ccd519af71397df4045e8a7f0a76b45cac5d50e3a199aeb20ead023ec7a7000a
MD5 41e696ce1fb2f863efd3716d61d4c127
BLAKE2b-256 23d4b0b950281a0ca31b7404009cdbbfd9b068a06e46e93d417505328f123a01

See more details on using hashes here.

File details

Details for the file textum-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for textum-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1f24240c388613db718a372bb96885ba74ed8f8c6796060e8895af51ebc928e3
MD5 a01bbcc77bfc8634c57c1d1cc916c361
BLAKE2b-256 23e51fe9256af941f96becf01597c2835fedc34dd6049f363facf7ee6b44b07e

See more details on using hashes here.

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