diff-match-patch


Namediff-match-patch JSON
Version 20241021 PyPI version JSON
download
home_pageNone
SummaryRepackaging of Google's Diff Match and Patch libraries.
upload_time2024-10-21 19:41:21
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # diff-match-patch

Google's [Diff Match and Patch][DMP] library, packaged for modern Python.

Since August 2024, Googles diff-match-patch library is archived, and 
this project will now track the [maintained fork][diff-match-patch-maintained].

[![version](https://img.shields.io/pypi/v/diff-match-patch.svg)](https://pypi.org/project/diff-match-patch)
[![changelog](https://img.shields.io/badge/change-log-blue)](https://github.com/diff-match-patch-python/diff-match-patch/blob/main/CHANGELOG.md)
[![license](https://img.shields.io/pypi/l/diff-match-patch.svg)](https://github.com/diff-match-patch-python/diff-match-patch/blob/master/LICENSE)

## Install

diff-match-patch is supported on Python 3.7 or newer.
You can install it from PyPI:

```shell
python -m pip install diff-match-patch
```

## Usage

Generating a patchset (analogous to unified diff) between two texts:

```python
from diff_match_patch import diff_match_patch

dmp = diff_match_patch()
patches = dmp.patch_make(text1, text2)
diff = dmp.patch_toText(patches)
```

Applying a patchset to a text can then be done with:

```python
from diff_match_patch import diff_match_patch

dmp = diff_match_patch()
patches = dmp.patch_fromText(diff)
new_text, _ = dmp.patch_apply(patches, text)
```

## Original README
The Diff Match and Patch libraries offer robust algorithms to perform the
operations required for synchronizing plain text.

1. Diff:
   * Compare two blocks of plain text and efficiently return a list of differences.
   * [Diff Demo](https://neil.fraser.name/software/diff_match_patch/demos/diff.html)
2. Match:
   * Given a search string, find its best fuzzy match in a block of plain text. Weighted for both accuracy and location.
   * [Match Demo](https://neil.fraser.name/software/diff_match_patch/demos/match.html)
3. Patch:
   * Apply a list of patches onto plain text. Use best-effort to apply patch even when the underlying text doesn't match.
   * [Patch Demo](https://neil.fraser.name/software/diff_match_patch/demos/patch.html)

Originally built in 2006 to power Google Docs, this library is now available in C++, C#, Dart, Java, JavaScript, Lua, Objective C, and Python.

### Reference

* [API](https://github.com/google/diff-match-patch/wiki/API) - Common API across all languages.
* [Line or Word Diffs](https://github.com/google/diff-match-patch/wiki/Line-or-Word-Diffs) - Less detailed diffs.
* [Plain Text vs. Structured Content](https://github.com/google/diff-match-patch/wiki/Plain-Text-vs.-Structured-Content) - How to deal with data like XML.
* [Unidiff](https://github.com/google/diff-match-patch/wiki/Unidiff) - The patch serialization format.
* [Support](https://groups.google.com/forum/#!forum/diff-match-patch) - Newsgroup for developers.

### Languages
Although each language port of Diff Match Patch uses the same API, there are some language-specific notes.

* [C++](https://github.com/google/diff-match-patch/wiki/Language:-Cpp)
* [C#](https://github.com/google/diff-match-patch/wiki/Language:-C%23)
* [Dart](https://github.com/google/diff-match-patch/wiki/Language:-Dart)
* [Java](https://github.com/google/diff-match-patch/wiki/Language:-Java)
* [JavaScript](https://github.com/google/diff-match-patch/wiki/Language:-JavaScript)
* [Lua](https://github.com/google/diff-match-patch/wiki/Language:-Lua)
* [Objective-C](https://github.com/google/diff-match-patch/wiki/Language:-Objective-C)
* [Python](https://github.com/google/diff-match-patch/wiki/Language:-Python)

A standardized speed test tracks the [relative performance of diffs](https://docs.google.com/spreadsheets/d/1zpZccuBpjMZTvL1nGDMKJc7rWL_m_drF4XKOJvB27Kc/edit#gid=0) in each language.

### Algorithms
This library implements [Myer's diff algorithm](https://neil.fraser.name/writing/diff/myers.pdf) which is generally considered to be the best general-purpose diff. A layer of [pre-diff speedups and post-diff cleanups](https://neil.fraser.name/writing/diff/) surround the diff algorithm, improving both performance and output quality.

This library also implements a [Bitap matching algorithm](https://neil.fraser.name/writing/patch/bitap.ps) at the heart of a [flexible matching and patching strategy](https://neil.fraser.name/writing/patch/).

[DMP]: https://github.com/google/diff-match-patch
[API]: https://github.com/google/diff-match-patch/wiki/API
[diff-match-patch-maintained]: https://github.com/dmsnell/diff-match-patch

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "diff-match-patch",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "Amethyst Reese <amethyst@n7.gg>",
    "keywords": null,
    "author": null,
    "author_email": "Neil Fraser <fraser@google.com>",
    "download_url": "https://files.pythonhosted.org/packages/0e/ad/32e1777dd57d8e85fa31e3a243af66c538245b8d64b7265bec9a61f2ca33/diff_match_patch-20241021.tar.gz",
    "platform": null,
    "description": "# diff-match-patch\n\nGoogle's [Diff Match and Patch][DMP] library, packaged for modern Python.\n\nSince August 2024, Googles diff-match-patch library is archived, and \nthis project will now track the [maintained fork][diff-match-patch-maintained].\n\n[![version](https://img.shields.io/pypi/v/diff-match-patch.svg)](https://pypi.org/project/diff-match-patch)\n[![changelog](https://img.shields.io/badge/change-log-blue)](https://github.com/diff-match-patch-python/diff-match-patch/blob/main/CHANGELOG.md)\n[![license](https://img.shields.io/pypi/l/diff-match-patch.svg)](https://github.com/diff-match-patch-python/diff-match-patch/blob/master/LICENSE)\n\n## Install\n\ndiff-match-patch is supported on Python 3.7 or newer.\nYou can install it from PyPI:\n\n```shell\npython -m pip install diff-match-patch\n```\n\n## Usage\n\nGenerating a patchset (analogous to unified diff) between two texts:\n\n```python\nfrom diff_match_patch import diff_match_patch\n\ndmp = diff_match_patch()\npatches = dmp.patch_make(text1, text2)\ndiff = dmp.patch_toText(patches)\n```\n\nApplying a patchset to a text can then be done with:\n\n```python\nfrom diff_match_patch import diff_match_patch\n\ndmp = diff_match_patch()\npatches = dmp.patch_fromText(diff)\nnew_text, _ = dmp.patch_apply(patches, text)\n```\n\n## Original README\nThe Diff Match and Patch libraries offer robust algorithms to perform the\noperations required for synchronizing plain text.\n\n1. Diff:\n   * Compare two blocks of plain text and efficiently return a list of differences.\n   * [Diff Demo](https://neil.fraser.name/software/diff_match_patch/demos/diff.html)\n2. Match:\n   * Given a search string, find its best fuzzy match in a block of plain text. Weighted for both accuracy and location.\n   * [Match Demo](https://neil.fraser.name/software/diff_match_patch/demos/match.html)\n3. Patch:\n   * Apply a list of patches onto plain text. Use best-effort to apply patch even when the underlying text doesn't match.\n   * [Patch Demo](https://neil.fraser.name/software/diff_match_patch/demos/patch.html)\n\nOriginally built in 2006 to power Google Docs, this library is now available in C++, C#, Dart, Java, JavaScript, Lua, Objective C, and Python.\n\n### Reference\n\n* [API](https://github.com/google/diff-match-patch/wiki/API) - Common API across all languages.\n* [Line or Word Diffs](https://github.com/google/diff-match-patch/wiki/Line-or-Word-Diffs) - Less detailed diffs.\n* [Plain Text vs. Structured Content](https://github.com/google/diff-match-patch/wiki/Plain-Text-vs.-Structured-Content) - How to deal with data like XML.\n* [Unidiff](https://github.com/google/diff-match-patch/wiki/Unidiff) - The patch serialization format.\n* [Support](https://groups.google.com/forum/#!forum/diff-match-patch) - Newsgroup for developers.\n\n### Languages\nAlthough each language port of Diff Match Patch uses the same API, there are some language-specific notes.\n\n* [C++](https://github.com/google/diff-match-patch/wiki/Language:-Cpp)\n* [C#](https://github.com/google/diff-match-patch/wiki/Language:-C%23)\n* [Dart](https://github.com/google/diff-match-patch/wiki/Language:-Dart)\n* [Java](https://github.com/google/diff-match-patch/wiki/Language:-Java)\n* [JavaScript](https://github.com/google/diff-match-patch/wiki/Language:-JavaScript)\n* [Lua](https://github.com/google/diff-match-patch/wiki/Language:-Lua)\n* [Objective-C](https://github.com/google/diff-match-patch/wiki/Language:-Objective-C)\n* [Python](https://github.com/google/diff-match-patch/wiki/Language:-Python)\n\nA standardized speed test tracks the [relative performance of diffs](https://docs.google.com/spreadsheets/d/1zpZccuBpjMZTvL1nGDMKJc7rWL_m_drF4XKOJvB27Kc/edit#gid=0) in each language.\n\n### Algorithms\nThis library implements [Myer's diff algorithm](https://neil.fraser.name/writing/diff/myers.pdf) which is generally considered to be the best general-purpose diff. A layer of [pre-diff speedups and post-diff cleanups](https://neil.fraser.name/writing/diff/) surround the diff algorithm, improving both performance and output quality.\n\nThis library also implements a [Bitap matching algorithm](https://neil.fraser.name/writing/patch/bitap.ps) at the heart of a [flexible matching and patching strategy](https://neil.fraser.name/writing/patch/).\n\n[DMP]: https://github.com/google/diff-match-patch\n[API]: https://github.com/google/diff-match-patch/wiki/API\n[diff-match-patch-maintained]: https://github.com/dmsnell/diff-match-patch\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Repackaging of Google's Diff Match and Patch libraries.",
    "version": "20241021",
    "project_urls": {
        "Changelog": "https://github.com/diff-match-patch-python/diff-match-patch/blob/main/CHANGELOG.md",
        "Github": "https://github.com/diff-match-patch-python/diff-match-patch"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f7bb2aa9b46a01197398b901e458974c20ed107935c26e44e37ad5b0e5511e44",
                "md5": "737f2e9d2ce38efbfffa97d66683c675",
                "sha256": "93cea333fb8b2bc0d181b0de5e16df50dd344ce64828226bda07728818936782"
            },
            "downloads": -1,
            "filename": "diff_match_patch-20241021-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "737f2e9d2ce38efbfffa97d66683c675",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 43252,
            "upload_time": "2024-10-21T19:41:19",
            "upload_time_iso_8601": "2024-10-21T19:41:19.914867Z",
            "url": "https://files.pythonhosted.org/packages/f7/bb/2aa9b46a01197398b901e458974c20ed107935c26e44e37ad5b0e5511e44/diff_match_patch-20241021-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0ead32e1777dd57d8e85fa31e3a243af66c538245b8d64b7265bec9a61f2ca33",
                "md5": "dd6de83ff4bcda48d424f5a73bc6888c",
                "sha256": "beae57a99fa48084532935ee2968b8661db861862ec82c6f21f4acdd6d835073"
            },
            "downloads": -1,
            "filename": "diff_match_patch-20241021.tar.gz",
            "has_sig": false,
            "md5_digest": "dd6de83ff4bcda48d424f5a73bc6888c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 39962,
            "upload_time": "2024-10-21T19:41:21",
            "upload_time_iso_8601": "2024-10-21T19:41:21.094882Z",
            "url": "https://files.pythonhosted.org/packages/0e/ad/32e1777dd57d8e85fa31e3a243af66c538245b8d64b7265bec9a61f2ca33/diff_match_patch-20241021.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-21 19:41:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "diff-match-patch-python",
    "github_project": "diff-match-patch",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "diff-match-patch"
}
        
Elapsed time: 1.25998s