A command line tool to apply substitutions to a text file
Project description
apply-subs
Apply a dictionnary (json) of substitutions to a text file.
Installing
$ pip install apply-subs
Examples
minimal
$ echo "Lorem ipsum dolor sit amet, consectetur adipiscing elit" > mytext.txt
$ echo '{"Hello": "Lorem ipsum", "goodbye": "adipiscing elit"}' > mysubs.json
$ apply-subs mytext.txt -s mysubs.json
will print the patched content
Hello dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore goodbye.
patch mode
In patch mode (-p/--patch
),
print a patch diff instead of the end result
--- mytext.txt
+++ mytext.txt (patched)
@@ -1 +1 @@
-Lorem ipsum dolor sit amet, consectetur adipiscing elit
+Hello dolor sit amet, consectetur goodbye
Use -cp/--cpatch/--colored-patch
for a colored output (when supported).
inplace substitutions
-i/--inplace
apply-subs --inplace mytext.txt -s mysubs.json
is equivalent to
apply-subs mytext.txt -s mysubs.json > mytext.txt
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
apply_subs-0.3.0.tar.gz
(16.0 kB
view details)
Built Distribution
File details
Details for the file apply_subs-0.3.0.tar.gz
.
File metadata
- Download URL: apply_subs-0.3.0.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b587a47caf7a3a2e7ac689fa21d97cdaa22a2b05f092c23be0c00e8aed6fa20 |
|
MD5 | 542ef036b0e6ec8f8dc7999e19a7f36c |
|
BLAKE2b-256 | 326b9030a490ba719b27caff1565c073c875b308c43008110fb5571223060e6a |
File details
Details for the file apply_subs-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: apply_subs-0.3.0-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 177ace87672452db3daeafa2da4ba4b011ee98f075c474ad2876bd67ca48ac6d |
|
MD5 | 6bec9c9bf7f0a69053a9a4d5c4120bd2 |
|
BLAKE2b-256 | 5e513991681dd2b8a9572b3a9caec0ec8a599bc08c7b47f7b76fffe07556b759 |