A unicode-resistant replacement for the classic `patch` utility
Project description
FTW Patch
Author: Fitzz TeXnik Welt
Email: FitzzTeXnikWelt@t-online.de
Abstract
A unicode-resistant replacement for the classic patch utility. This tool is designed to handle patches reliably, even when dealing with special characters or different file encodings that often cause issues with traditional tools.
Installation
Install ftw-patch easily via pipx:
pipx install ftw-patch
Features
- Unicode-Safe: Reliable processing of files with special characters and various encodings.
- Modern Python Support: Fully tested and optimized for Python 3.11 up to the latest version 3.15.
- Cross-Platform: Works seamlessly on Linux, macOS, and Windows.
- Configuration Support: Settings can be pre-defined in
pyproject.tomlor a custom user TOML file. - Robust Path Handling: Uses
platformdirsto ensure clean and standard-compliant file paths. - High Quality: Developed with high test coverage and verified via automated
toxbuilds. - Advanced Whitespace Handling: Options to normalize non-leading whitespace or ignore blank line differences.
- Safety First: Includes a
--dry-runmode to simulate changes and automatic backup functionality.
Usage (Command Line Interface)
ftw-patch is primarily used as a command-line tool.
Basic Syntax
ftwpatch [options] patch_file
Key Arguments & Options
patch_file: The path to the unified diff or patch file.-h, --help: Show the help message and exit.-p, --strip <count>: Set the number of leading path components to strip from file names before trying to find the file (default: 0).-d, --directory <dir>: Change the working directory to<dir>before starting to look for files to patch.--normalize-ws: Normalize non-leading whitespace (replace spaces/tabs with a single space) in context and patch lines before comparison.--ignore-bl: Ignore differences in the number of consecutive blank lines.--ignore-all-ws: Ignore all whitespace (leading, non-leading, and blank lines). This overrides--normalize-wsand--ignore-bl.--dry-run: Simulate the process without writing any changes to the file system.-b, --backup: Create a backup of each file before applying patches.--backupext <ext>: Extension for backup files (default:.bak). Supports special keywords:date,time, ordatetimefor ISO 8601 timestamps.--userconfig <path>: Path to a custom user TOML configuration file.
Note: Settings can also be loaded from
pyproject.tomlunder[tool.fitzzftw.patch].
Configuration via pyproject.toml
You can pre-configure ftwpatch in your project's pyproject.toml file. This is useful for setting permanent defaults for your project.
Add a section [tool.fitzzftw.patch] like this:
[tool.fitzzftw.patch]
backup = true
backupext = ".original"
normalize-ws = true
strip = 1
User Configuration and User Config File
If you want to use ftw-patch with the same settings across multiple projects, you can create a central user configuration file. The tool automatically searches for a patch.toml file in your standard user configuration directory.
Standard Locations:
- Linux:
~/.config/ftw-patch/patch.toml - macOS:
~/Library/Application Support/ftw-patch/patch.toml - Windows:
%AppData%\ftw-patch\patch.toml
Example patch.toml:
# Your personal defaults
backup = true
backupext = ".original"
normalize-ws = true
Note: You can override these defaults at any time by using command-line options or a project-specific
pyproject.toml. If you want to use a specific configuration file from a different location, use the--userconfig <path>option.
Licensing
This project uses different licenses for software and documentation:
Software (Code)
The source code of ftw-patch is licensed under the GNU General Public License, Version 2.
This allows free use, modification, and integration, provided that the terms of the GPLv2 (such as distributing the source code when you share the software) are met.
Documentation
The documentation (content in the docs/ directory and manuals) is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0).
- NC (Non-Commercial): Commercial use of the documentation (e.g., selling it as a printed book) is prohibited without express permission.
- BY / SA: Attribution and sharing under the same conditions are required.
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
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 ftw_patch-0.5.0.tar.gz.
File metadata
- Download URL: ftw_patch-0.5.0.tar.gz
- Upload date:
- Size: 36.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac7e470f240c58cb92413f12f63f38e3a73dbb02bed6a74068462e46cc50b56b
|
|
| MD5 |
1fe79dc13347b34bff8ccd59a00617d6
|
|
| BLAKE2b-256 |
80302b361517d05a97cca401116ab0d6f43da1dbd7fdc80a459a047aad92323c
|
Provenance
The following attestation bundles were made for ftw_patch-0.5.0.tar.gz:
Publisher:
ci.yml on fitzz-ftw/ftw-patch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ftw_patch-0.5.0.tar.gz -
Subject digest:
ac7e470f240c58cb92413f12f63f38e3a73dbb02bed6a74068462e46cc50b56b - Sigstore transparency entry: 1215254424
- Sigstore integration time:
-
Permalink:
fitzz-ftw/ftw-patch@119f01f0808c995cfb2538c5a9aa53cb97e67c42 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/fitzz-ftw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@119f01f0808c995cfb2538c5a9aa53cb97e67c42 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ftw_patch-0.5.0-py3-none-any.whl.
File metadata
- Download URL: ftw_patch-0.5.0-py3-none-any.whl
- Upload date:
- Size: 66.7 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 |
f1e3f0d84cebca658a0c04d5822d0b7cff6cec0d6ad634c0478da420fae0b750
|
|
| MD5 |
4fb5e92bc52b35b5cd5d02190d4e876a
|
|
| BLAKE2b-256 |
2c8eaacf621df89bca2e1c6cc663e9feda884ae7037f560b07cd46d84398ed4f
|
Provenance
The following attestation bundles were made for ftw_patch-0.5.0-py3-none-any.whl:
Publisher:
ci.yml on fitzz-ftw/ftw-patch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ftw_patch-0.5.0-py3-none-any.whl -
Subject digest:
f1e3f0d84cebca658a0c04d5822d0b7cff6cec0d6ad634c0478da420fae0b750 - Sigstore transparency entry: 1215254486
- Sigstore integration time:
-
Permalink:
fitzz-ftw/ftw-patch@119f01f0808c995cfb2538c5a9aa53cb97e67c42 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/fitzz-ftw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@119f01f0808c995cfb2538c5a9aa53cb97e67c42 -
Trigger Event:
push
-
Statement type: