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.1.2.tar.gz (88.0 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.1.2-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.1.2-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl (1.2 MB view details)

Uploaded PyPymanylinux: glibc 2.5+ i686

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

Uploaded PyPymanylinux: glibc 2.17+ s390x

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

Uploaded PyPymanylinux: glibc 2.17+ ppc64le

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

Uploaded PyPymanylinux: glibc 2.17+ ARMv7l

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

Uploaded PyPymanylinux: glibc 2.17+ ARM64

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

Uploaded PyPymanylinux: glibc 2.17+ s390x

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

Uploaded PyPymanylinux: glibc 2.17+ ppc64le

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

Uploaded PyPymanylinux: glibc 2.17+ ARMv7l

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

Uploaded PyPymanylinux: glibc 2.17+ ARM64

textum-0.1.2-cp39-abi3-win_amd64.whl (964.0 kB view details)

Uploaded CPython 3.9+Windows x86-64

textum-0.1.2-cp39-abi3-win32.whl (905.4 kB view details)

Uploaded CPython 3.9+Windows x86

textum-0.1.2-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.1.2-cp39-abi3-musllinux_1_2_i686.whl (1.3 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ i686

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

Uploaded CPython 3.9+musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

textum-0.1.2-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.1.2-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.1.2-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.1.2-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (990.3 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARMv7l

textum-0.1.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (996.8 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

textum-0.1.2-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl (1.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.5+ i686

textum-0.1.2-cp39-abi3-macosx_11_0_arm64.whl (944.2 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

textum-0.1.2-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.1.2.tar.gz.

File metadata

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

File hashes

Hashes for textum-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0b91b296a5474948bc4db63e793aee0747bd4fa69ada7f2b4aab91bc30a548ea
MD5 4c08fcf5a23718eef2e90d77517c17f3
BLAKE2b-256 47cee24032fc830c8e90ee5a9422bcb525d4df21369a1d2ba3def24fc14e98c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cebea0b2fe9429d60f209fdc020283b577f85be2d2fcc899cfa347abd070db09
MD5 0f664aa344b7bb563bcb910d2072b91d
BLAKE2b-256 09dae86838cf45a75bb8c0aab4b9cf2e383a16a8bf0fab338fa34b895da788e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 e2b2a2eaeb4c8e58598ad44d498b38d200047fa9227519d3427f344cc1aba4d7
MD5 adfa46340a312dbfc7ff4301602fe2d3
BLAKE2b-256 188cafc5c5c36c31c15ec909721a6c041546d9feb36233ee262eb04853e75e7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-pp310-pypy310_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 e966d51aa41a3a3160d876f5c00fb7073ca44c0ce4763bd7bfa190174147dd7b
MD5 6051aa3a23b4891904edc9ec6b758155
BLAKE2b-256 472773fb0a3b7be0e7fa5cef955feb929d339e195abc3b039179dc8592a83d73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 53c28d2aa40b9290a4cfe1d18aaccd4a9f072b26d148c48336e4cc1aef0df195
MD5 67949fa4ba89feb4c4e35cfb53f6b139
BLAKE2b-256 03738412d6dd1045a44a4652f33f32058904f95a30e3d7fd0c098a6a7a9bd1e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 d6232596dfec926b2a68b193a999d604b400c3bfd71460fa02b375d9033c6110
MD5 f4424e8fcd86ae9da3a965708eb7f02c
BLAKE2b-256 a9e7b5506c66ee80d4acd483027951d3ba779f7139505911a7c247a102ecfefb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5b91ad98e248b1ad9a6b59ba29928d122c84de394ec1700e070c56841864b41f
MD5 0ed154271f60826752d8338ab2d6a6f4
BLAKE2b-256 3bb40c2596ecf3567dcec316e0e64719121a24ec6a7c643e0e155353335b34cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-pp39-pypy39_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 44616321253fc7f0b1ae1c4372c064998b0f05b41a6c5aa9471528459c20d4cb
MD5 929acf9b117ea3ceb3423ea3e70bbbba
BLAKE2b-256 f40cc54359524f3e167136a50186a9228ae6318db803ef5cd73a41645c530ad7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 c537f9f6edafb3cec797cd94e17567af580e3ddfeca3fd7139c02e3d82d8e55e
MD5 fbccd7a506975d7933fba5eba8c1801e
BLAKE2b-256 e9b6a4f7dcb8ab0b01f61343a2f4a1191b5de9aa02de7ddf65034eed7f497da7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 147d3fbcf7652a7af41785591d52e0791f0f9a49526b240f3036a079de88d6af
MD5 b7d8b96a84f79efba4d51e744a2548e3
BLAKE2b-256 2bc1c9fb64af502550cf16672948b029d3ec07384c750e42e80aec5872a4420f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1920df0b42ac9a6be4c22f4a7e06cf1953ce17be6e16f3298551b37f4ba4ead0
MD5 69feef816cabf30b9ffd7691fe402f71
BLAKE2b-256 449852c144884317c195c0039485701ca405a248ccae261c6413c65b8d5dcb1b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: textum-0.1.2-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 964.0 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.9.6

File hashes

Hashes for textum-0.1.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ade31bbd724b2b0e68f10105c04a11a727d72147df4ccfb6097338a1b54a8726
MD5 7dbaf31bfa9081461b515fecbd6d2fc8
BLAKE2b-256 b67d0eb1b0fa78ebbe9b65b38bbb2da461e914e4ae580a9bf1709cf9a5d31f9d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for textum-0.1.2-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 efb506f6823286c4376cda467ce5576b2b49bc4e0557c69deb00df9f63a738bc
MD5 d0827f40624742eb1d6b292ecda72bb5
BLAKE2b-256 9ee5c7642804009f7a6a2c666da88ce814169f622275dbbe436ccf1c95394056

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 38f483b0f8fcfb95beb2a8c104b45cd3e5850faa30cb5a4f89b265fcdd89a351
MD5 55d26ad8a8b259f41987a209194e8074
BLAKE2b-256 5c1c19a5b9445270269a5be25ee5b870215a91a10d7b87444a9ec1c33997ee47

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 4959cb1bea87590c4d3ba5195cd235240cfdb820d8934fbc9ca3cc5319178f87
MD5 4f14afb54df75c59ecd46b0319af3590
BLAKE2b-256 cbf55b850d8b72ea860ca5963a6e7435c0658464cba9a0693b2601c7bfd54294

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 e5e42631eb7fcc073e849da2038689ebd1e3892a51cb94698ca8334693b60ae5
MD5 fb05eabcaedf2696703344f262d76e05
BLAKE2b-256 8daa3dabf6f5137b39f1193c49a8bc58657d45b57caa1751b2f425069185831e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 0c925017227aeca904ed79cebc6dffe59e18352026bb263c486dc69cbf78bb69
MD5 d8704fc07d842302897bb537be59a794
BLAKE2b-256 52473fd18362cd1488f86b295fa3ef05a5a319056cc0e442aee00e3c279006f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab199157b9e803bf653e8f1d71f8545e77df29ce62a6a23983b00a6be1d2a022
MD5 640bbd92459781d4ba0c1d5ebd5490b3
BLAKE2b-256 9e9d914582bcf7682da5ab4dd8aa0740e30c9789bf984c2a0579b24464ef4bfc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 ad31c6502f54990c2d12d4d1a1ab93104234dc57148493c8b7ef6ca37d83e36d
MD5 eed7408cfb82a00dc9edb45c61b771e2
BLAKE2b-256 bc00fb1bbb524a8909a2628c2dafb48743b4d301d13cdcd2d82aa198988b651d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 9a08a12315be5bf942333385311ca09b2432c3f6947ee21b18c4ecd1a28066f7
MD5 b63de1c605593cc2f2831618dcc3db43
BLAKE2b-256 fed27e6d8ffdf33fe30ebdd2502c866cd5c205b4dc422e99fbf16d2a6b5c01b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 9ba1b91ea9c3430cb1c905c273d0451886738b73458512a155e50abb0d517340
MD5 8d5a5a077c664b9b68d487c53fa656e1
BLAKE2b-256 c25a0c09616a8fc49e50ea60cec70d4b352db996d5abbfe5c38ddf807c7ae502

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4ff366283fce9ecd5a727ccfc90024b6f26d32eab8e0404279664db722c7894d
MD5 36fab9b4cb19632334e4f59aa0d12483
BLAKE2b-256 c40349c1bad6cc340c1d82caae2d88a5c1f973f84542a6517492ac67d7651c3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 4d418ddb7423fa834b520bf721ae29ff4ed41d8afa3efc748dd624c656b1ea99
MD5 f322cb9e16d521ab7699482e318e7eeb
BLAKE2b-256 52ed32321d8e31ab2e566978a4393ce1465e66a44748c31864595567d9be23a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8e467a361a3cb043b0bde1004f5187a957dff59cd45e383112f8f8fbba4eb6ea
MD5 5bb5e18266c2d8f49ac403b147af1071
BLAKE2b-256 e2087da61c505271fdd338e32974b661a1100f441821c9db9e0f389733d0bbd5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textum-0.1.2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0fd8a2a31fb7cb6db0f1b65090eae21a15e2d90c81e916180ba9d7cdf3975c23
MD5 2d09d93e2ed7d5c71507a77b00c309b4
BLAKE2b-256 be69fcbbabb7af522c693faccf0f14710555a25e6ba5d6f47cca01fe135270d4

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