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 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 mysubs.json
is equivalent to
apply-subs mytext.txt 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.2.1.tar.gz
(16.0 kB
view hashes)
Built Distribution
apply_subs-0.2.1-py3-none-any.whl
(16.2 kB
view hashes)
Close
Hashes for apply_subs-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 851d18e6134a5553cee9028285babdadb87f4f39bef9166f2d85bf2e760e61c3 |
|
MD5 | 6cdaebdd811ff731ff63441287a58657 |
|
BLAKE2b-256 | b40eb7e8a690d3744aa65d42d49e9e4283c564d97b4bd168edd0c09d6f9b5d50 |