Skip to main content

Do you want a fast and clean solution to patch your files and repositories? Use Python pypatchin package!

Project description

Do you want a fast and clean solution to patch your files and repositories? Use me, a Python pypatchin package!

I can patch your text, your files and your entire repositories. To do so, I rely on the high performance patching library diff-match-patch, making it accessible via Python code.

How to use

This project requires the diff-match-patch package:

pip install diff-match-patch

There are 2 main methods provided:

from pypatchin import patch

patch.compute_and_save_patches_for_list_of_files(all_files_to_patch, original_dir_name, latest_dir_name, patch_dir_name)
patch.apply_all_patches_to_files(all_files_to_patch, patch_dir_name, original_dir_name, patched_file_dir_name)

To compute patches for a list of files and to apply these patches to the same list of files.

Also, a method for checking the working is provided:

from pypatchin import compare

result = compare.compare_latest_vs_generated_list_of_files(all_files_to_patch, latest_dir_name, generated_dir_name)

Examples

See try_me.py and check_me.py scripts inside the example directory. They work on the sample repository inside original and latest directories.

Extras

Patch a text:

tmp_diff = compute_diff_from_strings("Test old text.", "Test new text.")
apply_diff_to_string("Text ole text", tmp_diff)

Patch a single file:

compute_and_save_patch_from_file(original_dir_name, original_file_name, latest_dir_name, latest_file_name, patch_dir_name, patch_file_name)
apply_patch_to_file(original_dir_name, original_file_name, patch_dir_name, patch_file_name, patched_file_dir_name, patched_file_name)

Tests

No tests present for now.

Contribute

Pull Requests are welcome.

Ensure the PR description clearly describes the problem and solution. It should include:

  • Name of the module modified

  • Reasons for modification

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

pypatchin-0.0.3.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

pypatchin-0.0.3-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file pypatchin-0.0.3.tar.gz.

File metadata

  • Download URL: pypatchin-0.0.3.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for pypatchin-0.0.3.tar.gz
Algorithm Hash digest
SHA256 e7ca33f8642463588e326255d0a835bdf90127c11966dad8d87a1bac4e549238
MD5 fd257350d08e97d5aa2e2a9c9b11002e
BLAKE2b-256 9d5afc7a506431e52865cdbce49b680d4b3d6fff5fb291f9ff3588d69f74852e

See more details on using hashes here.

File details

Details for the file pypatchin-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pypatchin-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for pypatchin-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 00fde79c44d3dd77d7c3376bd1cc36dbdb01a4ff96168b72bb22b4331fd4f6b0
MD5 b04001763bef2112c2881a8619a4cdf5
BLAKE2b-256 d7af35967f68d9f2d57e2ac47af6e0e1a22d9ab275cb5bcb680b94cb9574c815

See more details on using hashes here.

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