Bulk text replacement in files using dictionary mappings
Project description
textswap
Bulk text replacement in files using dictionary mappings.
Replace text across multiple files using find/replace dictionaries. Supports bidirectional replacement (keys-to-values or values-to-keys).
Installation
pip install textswap
Quick Start
- Create a config file (
config.json):
{
"dictionaries": {
"example": {
"old_text": "new_text",
"foo": "bar"
}
},
"ignore_extensions": [".exe", ".bin"],
"ignore_directories": ["node_modules", ".git"],
"ignore_file_prefixes": [".", "_"]
}
- Run:
textswap -f ./my_folder -d 1
Usage
# Interactive mode
textswap
# With options
textswap --folder ./src --direction 1 --config my_config.json
# Dry run (preview changes)
textswap -f ./src -d 1 --dry-run
# Reverse direction (values-to-keys)
textswap -f ./src -d 2
Options
| Option | Short | Description |
|---|---|---|
--folder |
-f |
Folder to process |
--direction |
-d |
1 = keys-to-values, 2 = values-to-keys |
--config |
-c |
Path to config file (default: config.json) |
--dict-name |
-n |
Dictionary name (auto-selects if only one) |
--dry-run |
Preview changes without modifying files |
Config Format
{
"dictionaries": {
"my_replacements": {
"find_this": "replace_with_this",
"old": "new"
}
},
"ignore_extensions": [".exe", ".dll"],
"ignore_directories": ["node_modules", "venv"],
"ignore_file_prefixes": [".", "_"]
}
License
GPL v3
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
Built Distribution
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 textswap-0.1.0.tar.gz.
File metadata
- Download URL: textswap-0.1.0.tar.gz
- Upload date:
- Size: 23.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98a50722686e52f2b2cc69870f71a2300f49e3cf3aef2e45c2b9bd396945a3eb
|
|
| MD5 |
e9c16c7a75b456d62a8eefd60a318200
|
|
| BLAKE2b-256 |
323d0754ed9d82332b4072fbe84fdaa5d28c95e5440ac67433790d900f56c54c
|
Provenance
The following attestation bundles were made for textswap-0.1.0.tar.gz:
Publisher:
publish.yml on cainky/textswap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
textswap-0.1.0.tar.gz -
Subject digest:
98a50722686e52f2b2cc69870f71a2300f49e3cf3aef2e45c2b9bd396945a3eb - Sigstore transparency entry: 807795331
- Sigstore integration time:
-
Permalink:
cainky/textswap@0a4d1839b81018785eb93706ea7e3394450d8de2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/cainky
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0a4d1839b81018785eb93706ea7e3394450d8de2 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file textswap-0.1.0-py3-none-any.whl.
File metadata
- Download URL: textswap-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ba7246cea2f47f4da73a0b2e23141a20f141d427f6c4839eb0c584dd421ed4f
|
|
| MD5 |
8ee06b731f9da7f789ea08d5eb3bd647
|
|
| BLAKE2b-256 |
c789c96434b3e3239239cad760b4524276c8604b9ff7c2ab24b34ed0a59e44f8
|
Provenance
The following attestation bundles were made for textswap-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on cainky/textswap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
textswap-0.1.0-py3-none-any.whl -
Subject digest:
4ba7246cea2f47f4da73a0b2e23141a20f141d427f6c4839eb0c584dd421ed4f - Sigstore transparency entry: 807795401
- Sigstore integration time:
-
Permalink:
cainky/textswap@0a4d1839b81018785eb93706ea7e3394450d8de2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/cainky
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0a4d1839b81018785eb93706ea7e3394450d8de2 -
Trigger Event:
workflow_dispatch
-
Statement type: