Skip to main content

Bulk text replacement in files using dictionary mappings

Project description

textswap

Bulk text replacement in files using dictionary mappings.

PyPI version License: GPL v3

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

  1. 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": [".", "_"]
}
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

textswap-0.1.0.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

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

textswap-0.1.0-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

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

Hashes for textswap-0.1.0.tar.gz
Algorithm Hash digest
SHA256 98a50722686e52f2b2cc69870f71a2300f49e3cf3aef2e45c2b9bd396945a3eb
MD5 e9c16c7a75b456d62a8eefd60a318200
BLAKE2b-256 323d0754ed9d82332b4072fbe84fdaa5d28c95e5440ac67433790d900f56c54c

See more details on using hashes here.

Provenance

The following attestation bundles were made for textswap-0.1.0.tar.gz:

Publisher: publish.yml on cainky/textswap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for textswap-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ba7246cea2f47f4da73a0b2e23141a20f141d427f6c4839eb0c584dd421ed4f
MD5 8ee06b731f9da7f789ea08d5eb3bd647
BLAKE2b-256 c789c96434b3e3239239cad760b4524276c8604b9ff7c2ab24b34ed0a59e44f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for textswap-0.1.0-py3-none-any.whl:

Publisher: publish.yml on cainky/textswap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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